// JavaScript Document
var _liger_sa = document.getElementsByTagName('script');
var _liger_path = _liger_sa[_liger_sa.length - 1].src;
_liger_path = _liger_path.substring(0, _liger_path.lastIndexOf('/'));
_liger_path = _liger_path.substring(0, _liger_path.lastIndexOf('/'));

(function ($)
{
	$.fn.ligerLayout3 = function (options)
	{
		return $.ligerui.run.call(this, "ligerLayout3", arguments);
	};

	$.fn.ligerGetLayout3Manager = function ()
	{
		return $.ligerui.run.call(this, "ligerGetLayout3Manager", arguments);
	};

	$.ligerDefaults.Layout3 = {
		topHeight: 100,
		topOffset: 0,
		bottomHeight: 26,
		leftWidth: 200,
		ctabsWidth: 90,
		centerWidth: 300,
		rightWidth: 200,
		outerMargin: 10,
		inWindow: true,     //是否以窗口的高度为准 height设置为百分比时可用
		heightDiff: 0,     //高度补差
		height: '100%',      //高度
		onHeightChanged: null,
		isLeftCollapse: false,      //初始化时 左边是否隐藏
		isRightCollapse: false,     //初始化时 右边是否隐藏
		allowLeftCollapse: true,      //是否允许 左边可以隐藏
		allowRightCollapse: true,     //是否允许 右边可以隐藏
		allowLeftResize: false,      //是否允许 左边可以调整大小
		allowRightResize: false,     //是否允许 右边可以调整大小
		allowTopResize: false,      //是否允许 头部可以调整大小
		allowBottomResize: false,     //是否允许 底部可以调整大小
		space: 1, //间隔 
		onEndResize: null,          //调整大小结束事件
		minLeftWidth: 80,            //调整左侧宽度时的最小允许宽度
		minRightWidth: 80,           //调整右侧宽度时的最小允许宽度
		onSizeChanged: null,
		onSelect: null,	//onSelect(type, data) //(type:module、lefttab、lefttree) 
		operItemEffect: 'gray',   //操作项效果：hide隐藏、gray变灰
		noPermission: '没有操作权限',
		defaultIcon: null,
		errorIcon: null,
		moduleContainerId: null,
		basepath: '',
		filepath: '',
		respath: '',
		iconpath: '',
		defaultPageSize: 20,
		getModulesUrl: null,
		getLeftTabsUrl: null,
		getLeftDataUrl: null,
		getCenterTabsUrl: null,
		getCenterDataUrl: null,
		closeButton: true,
		onClose: null,
		//自定义滚动条，使用jquery.nicescroll.js插件
        niceScroll: $.extend(true, {}, {
				enable: true,
				cursoropacitymin:0.5,
				cursoropacitymax:0.8,
				bouncescroll:false,
				cursorcolor:'#999',
				cursorwidth:"8px"
        	}, $.qxNiceScrollOpts || {})
		
    };

	$.ligerMethos.Layout3 = {};

	$.ligerui.controls.Layout3 = function (element, options)
	{
		$.ligerui.controls.Layout3.base.constructor.call(this, element, options);
	};
	$.ligerui.controls.Layout3.ligerExtend($.ligerui.core.UIComponent, {
        __getType: function ()
        {
            return 'Layout3';
        },
        __idPrev: function ()
        {
            return 'Layout3';
        },
        _extendMethods: function ()
        {
            return $.ligerMethos.Layout3;
        },
        _render: function ()
        {
            var g = this, p = this.options;
            g.layout = $(this.element);
            g.layout.addClass("l-layout");
            g.width = g.layout.width();
            //top
            if ($("> div[position=top]", g.layout).length > 0)
            {
                g.top = $("> div[position=top]", g.layout).wrap('<div class="l-layout-top" style="top:0px;"></div>').parent();
                g.top.content = $("> div[position=top]", g.top);
                if (!g.top.content.hasClass("l-layout-content"))
                {
                    g.top.content.addClass("l-layout-content");
				}
                g.topHeight = parseInt(p.topHeight);
                if (g.topHeight)
                {
                    g.top.height(g.topHeight);
                }
				//设置菜单
				//g.top.topleft = $(".topleft", g.top);
				//g.top.topright = $(".topright", g.top);
            }
            //bottom
            if ($("> div[position=bottom]", g.layout).length > 0)
            {
                g.bottom = $("> div[position=bottom]", g.layout).wrap('<div class="l-layout-bottom"></div>').parent();
                g.bottom.content = $("> div[position=bottom]", g.bottom);
                if (!g.bottom.content.hasClass("l-layout-content"))
                {
                    g.bottom.content.addClass("l-layout-content");
				}
                g.bottomHeight = parseInt(p.bottomHeight);
                if (g.bottomHeight)
                {
                    g.bottom.height(g.bottomHeight);
                }
                //set title
                var bottomtitle = g.bottom.content.attr("title");
                if (bottomtitle)
                {
                    g.bottom.header = $('<div class="l-layout-header"></div>');
                    g.bottom.prepend(g.bottom.header);
                    g.bottom.header.html(bottomtitle);
                    g.bottom.content.attr("title", "");
                }
            }
            //left
            if ($("> div[position=left]", g.layout).length > 0)
            {
                g.left = $("> div[position=left]", g.layout).wrap('<div class="l-layout-left" style="left:0px;"></div>').parent();
                
                g.left.tabsbar = $('<div class="l-layout-tabsbar"></div>');
				g.left.prepend(g.left.tabsbar);
                
                g.left.header = $('<div class="l-layout-header"><div class="l-layout-header-toggle"></div><div class="l-layout-header-inner"></div></div>');
                g.left.prepend(g.left.header);
                g.left.header.toggle = $(".l-layout-header-toggle", g.left.header);
                g.left.content = $("> div[position=left]", g.left);
                
                if (!g.left.content.hasClass("l-layout-content"))
                {
                    g.left.content.addClass("l-layout-content");
				}
                
                if (!p.allowLeftCollapse)
                {
                	$(".l-layout-header-toggle", g.left.header).remove();
                }
                //set title
                var lefttitle = g.left.content.attr("title");
                if (lefttitle)
                {
                    g.left.content.attr("title", "");
                    $(".l-layout-header-inner", g.left.header).html(lefttitle);
                }
                //set width
                g.leftWidth = parseInt(p.leftWidth);
                if (g.leftWidth)
                {
                    g.left.width(g.leftWidth);
				}
            }
            //tabs
            if ($("> div[position=ctabs]", g.layout).length > 0)
            {
            	g.ctabs = $("> div[position=ctabs]", g.layout).wrap('<div class="l-layout-ctabs" ></div>').parent();
            	g.ctabs.content = $("> div[position=ctabs]", g.ctabs);
                g.ctabs.content.addClass("l-layout-content");
            	
                g.ctabs.header = $('<div class="l-layout-header"><div class="l-layout-header-inner"></div></div>');
                g.ctabs.prepend(g.ctabs.header);
                
                g.ctabs.header.inner = $(".l-layout-header-inner", g.ctabs.header);
                var ctabstitle = g.ctabs.content.attr("title");
                if (ctabstitle)
                {
                    g.ctabs.content.removeAttr("title");
                    g.ctabs.header.inner.html(ctabstitle);
                }
                g.ctabsWidth = parseInt(p.ctabsWidth);
                if (g.ctabsWidth)
                {
                    g.ctabs.width(g.ctabsWidth);
				}
                g.ctabs.hide();
            }
            //center
            if ($("> div[position=center]", g.layout).length > 0)
            {
                g.center = $("> div[position=center]", g.layout).wrap('<div class="l-layout-center" ></div>').parent();
                g.center.content = $("> div[position=center]", g.center);
                g.center.content.addClass("l-layout-content");
                
                //set title
                g.center.header = $('<div class="l-layout-header"><div class="l-layout-header-inner"></div></div>');
                
                g.center.prepend(g.center.header);
                
                if(p.closeButton){
                	var closeButton = $('<div class="l-layout-header-closebtn">[ 关闭 ]</div>');
                	g.center.header.append(closeButton);
                	if(p.onClose){
                		closeButton.click(function(){
                			if(g.isFormOpen()){
                				g.closeForm();
                			}else{
                				p.onClose.call(g, this);
                			}
                		});
                	}
                }
                
                g.center.header.inner = $(".l-layout-header-inner", g.center.header);
                
                var centertitle = g.center.content.attr("title");
                if (centertitle)
                {
                    g.center.content.removeAttr("title");
                    g.center.header.inner.html(centertitle);
                }
                
                //set width
                g.centerWidth = parseInt(p.centerWidth);
                if (g.centerWidth)
                {
                    g.center.width(g.centerWidth);
				}
                g.center.loading = $(".l-layout-loading", g.center.content);
                g.center.mainiframe = $(".l-layout-mainiframe", g.center.content);
                g.center.maincontainer = $(".l-layout-maincontainer", g.center.content);
                g.center.formiframe = $(".l-layout-formiframe", g.center.content);
            }
            //right
            if ($("> div[position=right]", g.layout).length > 0)
            {
            	g.right = $("> div[position=right]", g.layout).wrap('<div class="l-layout-right"></div>').parent();
                g.right.header = $('<div class="l-layout-header"><div class="l-layout-header-toggle"></div><div class="l-layout-header-inner"></div></div>');
                g.right.prepend(g.right.header);
                g.right.header.toggle = $(".l-layout-header-toggle", g.right.header);
                
                if (!p.allowRightCollapse)
                {
                	$(".l-layout-header-toggle", g.right.header).remove();
                }
                g.right.content = $("> div[position=right]", g.right);
                
                if (!g.right.content.hasClass("l-layout-content"))
                {
                    g.right.content.addClass("l-layout-content");
				}
                //set title
                var righttitle = g.right.content.attr("title");
                if (righttitle)
                {
                    g.right.content.attr("title", "");
                    $(".l-layout-header-inner", g.right.header).html(righttitle);
                }
                
                //set width
                g.rightWidth = parseInt(p.rightWidth);
                if (g.rightWidth)
                {
                    g.right.width(g.rightWidth);
				}
            }
            //lock
            g.layout.lock = $("<div class='l-layout-lock'></div>");
            g.layout.append(g.layout.lock);
            //DropHandle
            g._addDropHandle();

            //Collapse
            g.isLeftCollapse = p.isLeftCollapse;
            g.isRightCollapse = p.isRightCollapse;
            g.leftCollapse = $('<div class="l-layout-collapse-left" style="display: none; "><div class="l-layout-collapse-left-toggle"></div></div>');
            g.rightCollapse = $('<div class="l-layout-collapse-right" style="display: none; "><div class="l-layout-collapse-right-toggle"></div></div>');
            g.layout.append(g.leftCollapse).append(g.rightCollapse);
            g.leftCollapse.toggle = $("> .l-layout-collapse-left-toggle", g.leftCollapse);
            g.rightCollapse.toggle = $("> .l-layout-collapse-right-toggle", g.rightCollapse);
            g._setCollapse();
            //init
            g._bulid();
            $(window).resize(function ()
            {
                g._onResize();
            });
            g.set(p);
            g.mask.height(g.layout.height());
            g._hideRight();
			g._onResize();
			
			//全局参数
			g.globalParam = {
				module: '',	//顶部菜单code
				lefttab: '',	//左侧底部标签id
				datatype: '',	//左侧树节点数据类型
				leftdata: '',	//左侧树节点数据id
				custdata: '',	//左侧树节点数据的自定义属性
				centertab: '',	//中间底部标签id
				centerdata: '',	//中间列表选中数据ID，多个时以半角分号分隔
				leftPath: ''	//左侧树节点数据id路径
			};
			g.globalObj = {
				module: null,	//顶部菜单数据
				lefttab: null,	//左侧底部标签数据
				leftdata: null,	//左侧树节点数据
				centertab: null,	//中间底部标签数据
				centerdata: [],	//中间列表选中数据数组
				centerConf: null//左侧表格配置数据
			};
			//动态加载页面的回调函数名
			g.globalFuncName = {
				uiInit: '__UiInit',
				uiCall: '__UiCall',
				searchCall: '__UiSearchCall',
				formChanged: '__UiFormChanged'
			};
			//动态加载页面的回调函数
			g.globalCallFunc = {
				uiCall: null,
				searchCall: null,
				formChanged: null
			};
			g.searchParams = [];
			g._timerid = null;
			//加载系统参数
			g._sysParams = p.sysParams;
        },
        //获取左侧导航树数据参数
        getLeftDataParam: function(leftDataName){
        	var g = this;
        	var param = {
        		datatype: g.globalParam.datatype,
        		leftdata: g.globalParam.leftdata,
        		custdata: g.globalParam.custdata,
        		leftPath: g.globalParam.leftPath
        	};
        	if(leftDataName){
        		param[leftDataName] = g.globalParam.leftdata;
        	}
        	return param;
        },
        //按类型获取左侧数据，结果为一个数组；如果isall不为true则仅获取第一个节点；如果左侧为accordion返回空数组;
        //如果只有一个则结果为一个长度为1的数组；如果有多个则按顺序返回一个数组；如果没有找到则结果为一个长度为0的数组
        getLeftDataByType: function(datatype, isall){
        	var g = this, nodes = g.left.ztreePathNode, arr=[];
        	if(!datatype || !nodes || !nodes.length || $('#leftZTree', g.left.content).size()==0){
        		return arr;
        	}
        	for(var i=0,n=nodes.length; i<n; i++){
        		if(nodes[i].type !== datatype){
        			continue;
        		}
        		arr.push(nodes[i]);
    			if(isall !== true){
    				break;
    			}
        	}
        	return arr;
        },
        //获取非空的全局参数
        _getGlobalParam: function(){
        	var g = this;
        	var param = {};
        	for(var key in g.globalParam)
        	{
        		var val = g.globalParam[key];
        		if(g._notEmpty(val))
        		{
        			param[key] = val;
        		}
        	}
        	return param;
        },
        //加载指定模块的布局配置
		loadModuleUI: function(moduleItem)
		{
			var g = this, p = this.options;
			g.hideCenterTabsbar();
			g._emptyFormiframe();
			//g._onResize();
			
			var code = moduleItem.code;
			g.globalParam.module = code;
			g.globalObj.module = moduleItem;
			
			g.globalParam.lefttab = '';
			g.globalParam.datatype = '';
			g.globalParam.leftdata = '';
			g.globalParam.leftPath = '';
			g.globalParam.custdata = '';
			g.globalParam.centertab = '';
			g.globalParam.centerdata = '';
			g.globalObj.lefttab = null;
			g.globalObj.datatype = null;
			g.globalObj.leftdata = null;
			g.globalObj.centertab = null;
			g.globalObj.centerdata = [];
			g.globalObj.centerConf = null;
			g.globalObj.rightconf = null;
			
			if(g._timerid){
				window.clearInterval(g._timerid);
				g._timerid = null;
			}
			
			var param = {};
			param.data = g._getGlobalParam();
			g.getAjaxData(p.getLeftTabsUrl, param, g.setLeftTabsbar);
		},
		
		setLeftTabsbar: function(left)
		{
			var g = this;
			if(!left)return;
			var ww = 0;
			if(g._notEmpty(left.width))
			{
				ww = parseInt(left.width) || 0;
			}
			g._setLeftWidth(ww);
			
			var items = left.tabs;
			if(!items || items.length==0)return;
			g.showLeftTabsbar();
			
			g.left.oldTreepath = g.left.ztreePath;
			g.left.oldType = g.left.type;
			g.left.type = left.type;
			g.left.initLoad = true;
			
			g.left.tabsbar.empty();
			for(var i in items)
			{
				var itm = items[i];
				itm['__itemIndex'] = i;
				var b = $('<div class="l-layout-tbtn"></div>');
				b.html(g._parseSysParam(itm.name));
				g.left.tabsbar.append(b);
				b.data('_itemIndex', i);
			}
			g.left.tabsbar.append('<div class="clear"></div>');
			var btns = $(".l-layout-tbtn", g.left.tabsbar);
			if(g.leftWidth)
			{
				btns.width(g.leftWidth/items.length - 1);
			}
			else
			{
				btns.css("padding","0 15px 0 15px");
			}
			btns.bind("click.layout3", items, function(event){
				var b = $(this);
				var itm = event.data[b.data('_itemIndex')];
				btns.removeClass("l-layout-tbtn-selected");
				b.removeClass("l-layout-tbtn-over");
				b.addClass("l-layout-tbtn-selected");
				g._leftTabsbarClick.call(g, itm, b.data('_itemIndex'));
			});
			btns.hover(function ()
			{
				if(!$(this).hasClass("l-layout-tbtn-selected"))
				{
					$(this).addClass("l-layout-tbtn-over");
				}
			}, function ()
			{
				$(this).removeClass("l-layout-tbtn-over");
			});
			
			var _clicked = false;
			var keeptab  = (g._isEmpty(left.keeptab) || left.keeptab=='true');
			if(keeptab && !!g.left.tabName){
				for(var i in items){
					if(g._parseSysParam(items[i].name) === g.left.tabName){
						btns.eq(parseInt(i)).trigger("click");
						_clicked = true;
						break;
					}
				}
			}
			if(!_clicked){
				btns.first().trigger("click");
			}
			
			if(items.length==1 && left.hide!='false')
			{
				g.hideLeftTabsbar();
			}
		},
		//左侧底部按钮点击处理
		_leftTabsbarClick: function(item, itemIndex)
		{
			var g = this, p = this.options;
			g.setLeftTitle(g._parseSysParam(item.title || item.name));
			g.globalParam.lefttab = item.id;
			g.globalObj.lefttab = item;
			
			g.globalParam.datatype = '';
			g.globalParam.leftdata = '';
			g.globalParam.leftPath = '';
			g.globalParam.custdata = '';
			g.globalParam.centertab = '';
			g.globalParam.centerdata = '';
			g.globalObj.leftdata = null;
			g.globalObj.centertab = null;
			g.globalObj.centerdata = [];
			g.globalObj.centerConf = null;
			g.globalObj.rightconf = null;
			
			if(g._timerid){
				window.clearInterval(g._timerid);
				g._timerid = null;
			}
			
			g.left.tabName = g._parseSysParam(item.name);
			
			if(g.left.niceScrollObj){
				g.left.niceScrollObj.remove();
        		g.left.niceScrollObj = null;
        	}
			
			if(item.type!='tree'){g.left.initLoad = false;}
			if(item.type=='tree')
			{
				if(!g.left.initLoad){
					g.left.oldTreepath = g.left.ztreePath;
					g.left.initLoad = true;
				}
				g.createLeftTree(item);
				if(p.onSelect){
					p.onSelect.call(g, 'lefttab', item);
				}
			}
			else if(item.type=='accordion')
			{
				g.createLeftAccordion(item);
			}
			else
			{
				alert('LEFT类型错误:'+item.type);
			}
		},
		//重新加载左侧树
		//id重新加载节点ID
		//parent如果为true在重新加载id节点的上级节点
		//expand是否展开父节点，默认不展开
		reloadLeftTree: function(id, parent, expand)
		{
			var g = this;
			if(!g.left.ZTreeObj)return;
			if(id==null)
			{
				g.left.ZTreeObj.reAsyncChildNodes(null, 'refresh', !expand);
				return;
			}
			var node = g.left.ZTreeObj.getNodeByParam('id', id);
			if(node==null)return;
			if(parent)
			{
				node = node.getParentNode();
			}
			g.left.ZTreeObj.reAsyncChildNodes(node, 'refresh', !expand);
		},
		//选中指定路径
		//path 数据ID数组，按层级保存
		selectLeftZTreeNode: function(path)
		{
			var g = this, p = this.options;
			if(!g.left.ZTreeObj)return;
			if(!path || !path.length)return;
			var z = g.left.ZTreeObj;
			var parentNode = null;
			var node = null;
			var i = 0;
			do{
				node = z.getNodeByParam("id", path[i], parentNode);
				if(!node){
					if(parentNode && parentNode.isParent && !parentNode.zAsync){
						parentNode._ishexpand = true;
						z._hexpandpath = path;
						z.expandNode(parentNode, true, false, true, true);
					}else if(parentNode){
						$("#"+parentNode.tId+$.fn.zTree.consts.id.A, z.setting.treeObj).click();
						g.left.oldTreepath = null;
					}else{
						var nodes = z.getNodes();
						if(nodes && nodes.length){
							$("#"+nodes[0].tId+$.fn.zTree.consts.id.A, z.setting.treeObj).click();
							g.left.oldTreepath = null;
						}
					}
					break;
				}
				if(parentNode){
					z.expandNode(parentNode, true);
				}
				if(i+1 == path.length){//选中当前节点
					$("#"+node.tId+$.fn.zTree.consts.id.A, z.setting.treeObj).click();
					g.left.oldTreepath = null;
					if(node.isParent){
						z.expandNode(node, true, false, true, true);
					}
					break;
				}
				parentNode = node;
				i++;
			}while(i<path.length);
		},
		//获取指定树节点的DOM对象
		_getZTreeNodeDom: function(dataId, parentNode)
		{
			var g = this, p = this.options;
			if(!g.left.ZTreeObj)return null;
			var z = g.left.ZTreeObj;
			var node = z.getNodeByParam("id", dataId, parentNode);
			if(!node)return null;
			return $("#"+node.tId+$.fn.zTree.consts.id.A, z.setting.treeObj);
		},
		//创建左侧树
		createLeftTree: function(item)
		{
			var g = this, p = this.options;
			g._emptyLeft();
			var leftZTree = g.left.ZTree = $('<ul id="leftZTree" class="ztree"></ul>');
			g.left.content.append(leftZTree);
			
			//滚动条
            if(p.niceScroll && p.niceScroll.enable && $.fn.niceScroll){
            	if(g.left.niceScrollObj){
            		g.left.niceScrollObj.remove();
            		g.left.niceScrollObj = null;
            	}
            	g.left.niceScrollObj = g.left.content.niceScroll(leftZTree, p.niceScroll);
            	g.left.niceScrollObj.onResize();
            	g.left.content.unbind('focus.niceScroll').bind('focus.niceScroll', function(){g.left.content.blur();});
			}else{
				leftZTree.css("height", (g.left.content.innerHeight()-10)+"px");
			}
			
			if(g.left.initLoad && !!g.left.type && g.left.type == g.left.oldType){
				g.left.initLoad = false;
			}else{
				g.left.oldTreepath = null;
			}
			
			var url = g._getUrl(item.url);
			url = g._parseSysParam(url);
			if(url.indexOf('?')==-1)
			{
				url += '?';
			}else{
				url += '&';
			}
			var params = g._getGlobalParam();
			params.r = function(){return ""+Math.random();};
			var z = g.left.ZTreeObj = $.fn.zTree.init(leftZTree, {
				async:{
					enable:true,type:'get',autoParam:['id=pid','type=pdatatype','custdata=pcustdata'],otherParam: params, url: url,
					dataFilter: function(treeId, parentNode, responseData)
					{
						var conver = function(tnodes)
						{
							for(var i in tnodes)
							{
								var tnode = tnodes[i];
								if(g._notEmpty(tnode.icon))
								{
									tnode.icon = g._getIconPath(tnode.icon);
								}
								if(tnode.children)
								{
									conver(tnode.children);
								}
							}
						};
						conver(responseData);
						return responseData;
					}
				},
				view:{selectedMulti:false,autoCancelSelected:false,dblClickExpand:false},
				callback:{
					onAsyncSuccess:function(event, treeId, treeNode, msg)//加载完成事件
					{
						var _zt = $.fn.zTree.getZTreeObj(treeId);
						if(g.left.oldTreepath && g.left.oldTreepath.length){
							var path = g.left.oldTreepath;
							g.selectLeftZTreeNode(path);
						}else{
							if(!treeNode || treeNode.__isinitexpand){//根节点或初始化
								if(!item.select){
									item.select = '0';
								}
								var arr = item.select.split('|');
								var level = parseInt(arr[0]);
								var index = (arr.length>1)?parseInt(arr[1]):0;
								//加载根节点
								if(!treeNode){
									var nodes = _zt.getNodes();
									if(level==0){//选中第一层中的节点
										if(nodes && nodes.length>0){
											index = (index>=nodes.length)?0:index;
										}
										_zt.selectNode(nodes[index]);
										$("#"+nodes[index].tId+this.consts.id.A, _zt.setting.treeObj).click();
										_zt._nselected = true;
									}else{//level>0
										_zt._lfnode = (nodes && nodes.length>0)?nodes[0]:null;
									}
								}else if(treeNode == _zt._lfnode){//加载非根节点
									var nodes = treeNode.children;
									if(treeNode.level+1==level){//选中当前层节点
										if(nodes && nodes.length>0){
											index = (index>=nodes.length)?0:index;
										}
										_zt.selectNode(nodes[index]);
										$("#"+nodes[index].tId+this.consts.id.A, _zt.setting.treeObj).click();
										_zt._nselected = true;
									}else if(treeNode.level+1<level){//要展开后代层次节点
										_zt._lfnode = (nodes && nodes.length>0)?nodes[0]:null;
									}
								}
								//处理默认展开节点（仅处理顶层节点）
								if(treeNode!=null || item.expand==null)return;
								var expand = item.expand.split('|')[0];
								if(expand!='first' && expand!='all')return;
								var nodes = _zt.getNodes();
								if(!nodes || nodes.length==0)return;
								
								//展开第一个节点
								if(expand=='first')
								{
									nodes[0].__isinitexpand=true;
									_zt.expandNode(nodes[0], true, false, true, true);
								}
								else if(expand=='all')
								{
									for(var i in nodes)
									{
										nodes[i].__isinitexpand=true;
										_zt.expandNode(nodes[i], true, false, true, true);
									}
								}
							}
							if(treeNode && treeNode._ishexpand){
								var _hp= _zt._hexpandpath;
								var _n = _zt.getNodeByParam("id", _hp[treeNode.level+1], treeNode);
								if(_n){
									if(_n.level+1==_hp.length){//选中当前层节点
										_zt.selectNode(_n);
										$("#"+_n.tId+this.consts.id.A, _zt.setting.treeObj).click();
									}else if(_n.level+1<_hp.length){//要选中后代层次节点
										_n._ishexpand=true;
										_zt.expandNode(_n, true, false, true, true);
									}
								}
							}
						}
					},
					onCollapse: function()
					{
						if(g.left.niceScrollObj){
							g.left.niceScrollObj.onResize();
						}
					},
					onExpand:function(event, treeId, treeNode)//展开节点事件
					{
						if(g.left.niceScrollObj && g.left.ZTree.outerHeight(true) > g.left.content.height()){
							g.left.niceScrollObj.onResize();
						}
						var _zt = $.fn.zTree.getZTreeObj(treeId);
						if(treeNode.__isinitexpand){
							if(!_zt._nselected){
								var sarr = item.select.split('|');
								var slevel = parseInt(sarr[0]);
								var sindex = (sarr.length>1)?parseInt(sarr[1]):0;
								var snodes = treeNode.children;
								if(treeNode.level+1==slevel){
									if(snodes && snodes.length>0){
										sindex = (sindex>=snodes.length)?0:sindex;
									}
									_zt.selectNode(snodes[sindex]);
									$("#"+snodes[sindex].tId+this.consts.id.A, _zt.setting.treeObj).click();
									_zt._nselected = true;
								}
							}
							delete treeNode.__isinitexpand;
							var arr = item.expand.split('|');
							var expand = arr[0];
							var level = (arr.length>1)?parseInt(arr[1]):0;
							if(treeNode.level>=level)return;
							var nodes = treeNode.children;
							if(!nodes || nodes.length==0)return;
							if(expand=='first')
							{
								nodes[0].__isinitexpand=true;
								_zt.expandNode(nodes[0], true, false, true, true);
							}
							else if(expand=='all')
							{
								for(var i in nodes)
								{
									nodes[i].__isinitexpand=true;
									_zt.expandNode(nodes[i], true, false, true, true);
								}
							}
							
						}
						if(treeNode._ishexpand){
							delete treeNode._ishexpand;
						}
					},
			 		onClick:function(event, treeId, treeNode, clickFlag)//节点点击事件
			 		{
						if(treeNode.notclick!==true && treeNode.notclick!=='true'){
							g.left.ztreePath = [];
							g.left.ztreePathNode = [];
							var _n = treeNode;
							do{
								g.left.ztreePath.push(_n.id);
								g.left.ztreePathNode.push(_n);
								_n = _n.getParentNode();
							}while(_n!=null);
							g.left.ztreePath.reverse();
							g.left.ztreePathNode.reverse();
							g.globalParam.leftPath = g.left.ztreePath.join(';');
							g._leftClick(treeNode);
							if(p.onSelect){
								p.onSelect.call(g, 'lefttree', treeNode);
							}
						}
						if(!treeNode.open){
							z.expandNode(treeNode, true, false, true, true);
						}
				 	}
				}//callback
			});
			g.left.initLoad = false;
		},
		//创建左侧折叠面板
		createLeftAccordion: function(item)
		{
			var g = this, p = this.options;
			g._emptyLeft();
			g.left.accordioncon = $('<div id="leftAccordion" class="accordion"></div>');
			g.left.content.append(g.left.accordioncon);
			g.left.accordioncon.css("height", (g.left.content.innerHeight())+"px");
			
			var url = item.url;
			if(g._isEmpty(url)){
				url = p.getLeftDataUrl;
			}else{
				url = g._getUrl(item.url);
				url = g._parseSysParam(url);
			}
			if(url.indexOf('?')==-1){
				url += '?';
			}else{
				url += '&';
			}
			url += $.param(g._getGlobalParam());
			url += '&r='+Math.random();
			
			if($.ligerui.get(g.left.accordioncon.attr("id")))
			{
				$.ligerui.remove(g.left.accordioncon.attr("id"));
			}
			g.left.accordion = g.left.accordioncon.ligerAccordion2({
				basepath: p.basepath,
				url: url,
		        iconpath: p.iconpath,
		        height: 'auto',
		        expand: item.expand,
		        layout: g,
		        onClick: function(data, srctype, ztree){
					if(srctype=='tree'){
						g.left.ZTreeObj = ztree;
					}
					g._leftClick(data);
				},
			 	onCreated: function()
			 	{
					g.left.accordion.clickItem(0, 0);
			 	}
			});
		},
		//左侧点击事件
		_leftClick: function(data)
		{
			var g = this, p = this.options;
			var olddatatype = g.globalParam.datatype;
			g.globalParam.datatype = data.type;
			g.globalParam.leftdata = data.id;
			g.globalParam.custdata = data.custdata;
			g.globalObj.leftdata = data;

			var ctab = g.globalObj.centertab;

			g.globalParam.centerdata = '';
			g.globalObj.centerdata = [];
			g.searchParams = [];

			g._emptyFormiframe();
			var called = false;
			if(olddatatype == data.type && ctab && data.dynamic !== true)
			{
				//数据类型相同时重新加载当前标签
				if(ctab.type=='table')
				{
					if(ctab.reload==null || ctab.reload=='')
					{
						ctab.reload = 'func';
					}
					if(ctab.reload=='func')
					{
						var t = g.center.tablegrid;
						var _parms = [];
						var _lfield = (g.globalObj.leftdata!=null)?g.globalObj.leftdata.field:null;
						if(g._notEmpty(_lfield) && _lfield!='leftdata' && g._notEmpty(g.globalParam.leftdata))
						{
							_parms.push({name:_lfield, value:g.globalParam.leftdata});
						}
						
						//设置搜索表单参数
						g.searchParams = g.getSearchParams(true);
						for(var si in g.searchParams){
							var sp = g.searchParams[si];
							_parms.push({name:sp.name, value:sp.value});
						}
						
						//框架参数
						var gparam = g._getGlobalParam();
						for(var key in gparam)
						{
							_parms.push({name:key, value:gparam[key]});
						}

						g.center.tablegrid.set('newPage', 1);
						g.center.tablegrid.set({parms: _parms});
						g.center.tablegrid.loadData(true);
						
						called = true;
					}
				}
				if(ctab.type=='page' || ctab.type=='iframe')
				{
					if(ctab.reload==null || ctab.reload=='')
					{
						ctab.reload = 'tab';
					}
					if(ctab.reload=='func')
					{
						if(g.globalCallFunc.uiCall)
						{
							g.searchParams = g.getSearchParams(true);
							g.globalCallFunc.uiCall.call(g, g);
						}
						called = true;
					}
				}
				if(ctab.reload=='tab')
				{
					g.center._reload = true;
					g.searchParams = g.getSearchParams(true);
					var i = g.globalObj.centertab['__itemIndex'];
					$("> div:eq("+i+")", g.ctabs.content).click();
					called = true;
				}
			}
			if(called)
			{
				g._reloadRight(true);
				return;
			}
			//数据类型不同时重新加载框架
			g.globalParam.centertab = '';
			g.globalParam.centerdata = '';
			g.globalObj.centertab = null;
			g.globalObj.centerdata = [];
			g.globalObj.centerConf = null;
			g.globalObj.rightconf = null;

			if(g._timerid){
				window.clearInterval(g._timerid);
				g._timerid = null;
			}
			
			var param = {};
			param.data = g._getGlobalParam();
			g.getAjaxData(p.getCenterTabsUrl, param, g.setCenterTabsbar);
		},
		setCenterTabsbar: function(center)
		{
			var g = this, p = this.options;
			if(!center)return;
			//标签
			var items = center.tabs;
			if(!items || items.length==0)return;
			if(!g.ctabs)return;

			if(items.length > 1){
				g.showCenterTabsbar();
			}else{
				g.hideCenterTabsbar();
			}
			
			var ctabsContent = g.ctabs.content;
			ctabsContent.empty();
			for(var i=0; i<items.length; i++)
			{
				var itm = items[i], name = g._parseSysParam(itm.name);
				itm['__itemIndex'] = i;
				var tabBtn = $('<div id="ctabs_'+itm.id+'" class="l-layout-ctabs-btn"><p>'+name+' <span>&gt;</span></p></div>');
				ctabsContent.append(tabBtn);
				if(itm.title){
					tabBtn.attr('title', itm.title);
				}
				tabBtn.data('_itemIndex', i);
				if(i == 0){
					tabBtn.addClass('l-layout-ctabs-btn-first');
				}
			}
			
			var btns = $(".l-layout-ctabs-btn", ctabsContent);

			btns.bind("click.layout3", items, function(event){
				var tabBtn = $(this), itm = event.data[tabBtn.data('_itemIndex')];
				btns.removeClass("l-layout-ctabs-btn-selected");
				tabBtn.removeClass("l-layout-ctabs-btn-over");
				tabBtn.addClass("l-layout-ctabs-btn-selected");
				
				g._centerTabsbarClick(itm, tabBtn.data('_itemIndex'));
			});
			btns.hover(function ()
			{
				if(!$(this).hasClass("l-layout-ctabs-btn-selected"))
				{
					$(this).addClass("l-layout-ctabs-btn-over");
				}
			}, function ()
			{
				$(this).removeClass("l-layout-ctabs-btn-over");
			});
			var _clicked = false;
			if((g._isEmpty(center.keeptab) || center.keeptab=='true') && g.center.tabName){
				for(var i=0; i<items.length; i++){
					if(g._parseSysParam(items[i].name) === g.center.tabName){
						btns.eq(parseInt(i)).trigger("click");
						_clicked = true;
					}
				}
			}
			if(!_clicked){
				btns.first().trigger("click");
			}
			
		},
		//中间标签点击处理
		_centerTabsbarClick: function(item, itemIndex)
		{
			var g = this, p = this.options;
			g._emptyFormiframe();
			var reclick = (g.globalObj.centertab == item);
			if(item.type!='func')
			{
				var tit = g._parseSysParam(item.title || item.name);
				if(g.globalObj.leftdata){
					tit = tit.replace('{LEFT}', (g.globalObj.leftdata.name||''));
				}
				g.setCenterTitle(tit);
				g.globalParam.centertab = item.id;
				g.globalObj.centertab = item;
				
				g.globalParam.centerdata = '';
				g.globalObj.centerdata = [];
				g.globalObj.centerConf = null;
				if(!g.center._reload){
					g.globalObj.rightconf = null;
				}
				g.center._reload = false;
				
				if(g._timerid){
					window.clearInterval(g._timerid);
					g._timerid = null;
				}
				
				g.center.tabName = g._parseSysParam(item.name);
			}
			var param = {};
			param.data = g._getGlobalParam();
			
			if(item.type=='table' || item.type=='iframe'){
				g.center.content.css({"overflow-y":"hidden"});
			}else{
				g.center.content.css({"overflow-y":"auto"});
			}
			
			if(item.type=='table')//表格
			{
				g.center.mainiframe.hide();
				g.center.mainiframe.attr("src", "about:blank");
				g.center.loading.hide();
				g.center.maincontainer.show();
				
				g.getAjaxData(p.getCenterDataUrl, param, g.createCenterTable, reclick);
			}
			else if(item.type=='iframe')//使用iframe加载页面
			{
				g.center.maincontainer.hide();
				g.center.mainiframe.show();
				g._emptyCenter();
				g.center.loading.show();
				var src = g._getUrl(item.url);
				src = g._parseSysParam(src);
				if(item.uiparam!=='false')
				{
					if(src.indexOf('?')==-1){
						src += '?';
					}else{
						src += '&';
					}
					src += $.param(param.data);
					src += '&r='+Math.random();
				}
				g.center.mainiframe.attr("src", src).unbind('load.layout3').bind('load.layout3', function (){
					g.center.loading.hide();
					g.center.mainiframe.unbind('load.layout3');
					
					if(!g._isLocalUrl(g.center.mainiframe[0].src))return;
					
					//初始化
					var icwin = g.center.mainiframe[0].contentWindow;
					if(!icwin)return;
					g._callInit(icwin, g.globalFuncName.uiInit, item);
					
					//更新方法
					if(typeof(icwin[g.globalFuncName.uiCall])=='function')
					{
						g.globalCallFunc.uiCall = icwin[g.globalFuncName.uiCall];
					}
					//搜索方法
					if(typeof(icwin[g.globalFuncName.searchCall])=='function')
					{
						g.globalCallFunc.searchCall = icwin[g.globalFuncName.searchCall];
					}
				});
				if(!g._reloadRight(reclick)){
					g.getAjaxData(p.getCenterDataUrl, param, g._createRightPanel);
				}
			}
			else
			{
				alert('CENTER类型错误:'+item.type);
			}
		},
		
		getSearchParams: function(isreload){
			var g = this, p = this.options;
			var searchParams = [];
			//设置搜索表单参数
			if(g.searches){
				var searches = g.searches;
				var searchList = searches.searchList;
				for(var j=0; j<searchList.length; j++)
				{
					var s = searchList[j];
					var _sfitm = g.searchForm[s.field];
					if(s.type=='newline' || s.type=='button'){
						continue;
					}
					else if(s.type=='select')
					{
						if(!!isreload)
						{
							if(s.reset=='true'){
								_sfitm.selectValue(s.initValue || '');
								if(s.initValue){
									searchParams.push({name:s.field, value:_sfitm.getValue()});
								}
							}else if(s.reset=='reload'){
								_sfitm.selectValue(s.initValue || '');
								if(s.initValue){
									searchParams.push({name:s.field, value:_sfitm.getValue()});
								}
								//重新加载数据
								var selectUrl = '';
								if(g._notEmpty(s.url)){
									selectUrl = g._getUrl(s.url);
								}
								if(g._notEmpty(selectUrl)){
									if(selectUrl.indexOf('?')==-1){
										selectUrl += '?';
									}else{
										selectUrl += '&';
									}
									selectUrl += $.param(g._getGlobalParam());
								}
								if(_sfitm.options.url){
									_sfitm.setUrl(selectUrl);
								}else if(_sfitm.options.tree){
									if(_sfitm.treeManager){
										_sfitm.treeManager.set('url', selectUrl);
									}else{
										_sfitm.options.tree.url = selectUrl;
										_sfitm.setTree(_sfitm.options.tree);
									}
								}
							}else{
								searchParams.push({name:s.field, value:_sfitm.getValue()});
							}
						}else{
							searchParams.push({name:s.field, value:_sfitm.getValue()});
						}
					}
					else if(s.type=='select-win')
					{
						if(!!isreload && s.reset=='true'){
							_sfitm.reset(s.initValue || '');
							if(s.initValue){
								searchParams.push({name:s.field, value:_sfitm.getValue()});
							}
						}else{
							searchParams.push({name:s.field, value:_sfitm.getValue(), text: _sfitm.getText()});
						}
					}
					else if(s.type=='date')
					{
						if(!!isreload && s.reset=='true'){
							_sfitm._setValue(s.initValue || '');
							if(s.initValue){
								searchParams.push({name:s.field, value:_sfitm.getTextValue()});
							}
						}else{
							searchParams.push({name:s.field, value:_sfitm.getTextValue()});
						}
					}
					else{
						if(!!isreload && s.reset=='true'){
							_sfitm._setValue(s.initValue || '');
							if(s.initValue){
								searchParams.push({name:s.field, value:_sfitm._getValue()});
							}
						}else{
							searchParams.push({name:s.field, value:_sfitm._getValue()});
						}
					}
				}//for=j
			}
			
			return searchParams;
		},
		//创建搜索表单项
		_createSearchItems: function(searchItem, __param, fieldHead, defaultWidth, formObj, searchForm){
			var g = this, p = this.options;
			var s = searchItem;
			
			var _spa = null;
			if(!s.reset || s.reset==='false'){
				var gsp = g.searchParams || [];
				for(var i in gsp){
					var sp = gsp[i];
					if(sp && sp.name == s.field){
						_spa = sp;
						break;
					}
				}
			}
			
			if(s.type=='select')
			{
				var p2 = {};
				$.extend(p2, {
					defaultValue: "",
					defaultText: "---请选择---",
					valueField: 'id',
					textField: 'name',
					width: defaultWidth,
					selectBoxHeight: 200,
					treeLeafOnly:false,
					forbidTreeCancel:true
				}, __param);
				p2.valueFieldID = fieldHead +s.field;
				if(_spa && _spa.value){
					p2.initValue = _spa.value;
				}else if(s.initValue){
					p2.initValue = s.initValue;
				}
				if(g._notEmpty(s.width))
				{
					p2.width = parseInt(s.width);
				}
				if(!p2.selectBoxWidth)
				{
					p2.selectBoxWidth = p2.width;
				}
				if(g._notEmpty(s.url) && !p2.url)
				{
					p2.url = g._getUrl(s.url);
				}
				if(g._notEmpty(p2.url))
				{
					var param = g._getGlobalParam();
					if(p2.url.indexOf('?')==-1){
						p2.url += '?';
					}else{
						p2.url += '&';
					}
					p2.url += $.param(param);
				}
				if(p2.tree)//树模式
				{
					var ptree = {};
					$.extend(ptree, {
						idFieldName:'id',
						textFieldName:'name',
						checkbox: false,
						isExpandCurrent:false,
						isAsync:true,
						isExpand: false,
						isLeaf: function(node){return (node.isParent!==true && node.isParent!=='true');}
					}, p2.tree);
					p2.tree = ptree;
					if(g._notEmpty(p2.url)){
						p2.tree.url = p2.url;
						p2.url = null;
					}
				}
				if(p2.onSelected){
					p2.onSelected = function(id, text, node){
						this.options.onSelected.call(this, id, text, node, g);
					};
				}else if(g._notEmpty(s.child)){
					s.childUrl = g._getUrl(s.childUrl);
					p2.onSelected = function(id, text, node){
						var cfg = this._configData;
						var csel = this._self_searchForm[cfg.child];
						if(!csel)return;
						if(id!=''){
							csel.reloadUrl(cfg.childUrl.replace('@ID', id));
			            }else{
			            	csel.reloadUrl();
			            }
					};
				}
				
				if($.ligerui.get(fieldHead +s.field+'_txt'))
				{
					$.ligerui.remove(fieldHead +s.field+'_txt');
				}
				var cb = $('#'+fieldHead +s.field+'_txt', formObj).ligerComboBox(p2);
				cb._configData = s;
				cb._self_searchForm = searchForm;
				searchForm[s.field] = cb;
			}
			else if(s.type == 'select-win')
			{
				var _SW = function(opt){
					var swThis = this;
					this.init=function(){
						this._id = opt._idObj;
						this._txt = opt._txtObj;
						if($.ligerui.get(opt._txtId))
						{
							$.ligerui.remove(opt._txtId);
						}
						this._ligerTxt = this._txt.ligerTextBox(opt.txtOptions);
						
						if(!this._txt.hasClass('l-layout_select_win')){
							this._txt.addClass('l-layout_select_win');
						}
						this._txt.width(this._txt.width()-parseInt(this._txt.css('paddingRight')));
						
						this._txt.css("ime-mode","disabled");
						this._txt.bind("keydown",function(e){return false;});
						this._txt.bind("paste",function(){return false;});
						this._txt.bind("dragenter", function(){return false;});
						this._txt.bind("contextmenu", function(){return false;});
						try{ this._txt.bind("dragover",function(){return false;}); }catch (err){}
						this._txt.focus(function(){$(this).blur();});
						this._txt.mousedown(function(){$(this).addClass('l-layout_select_win_gray');}).mouseup(function(){$(this).removeClass('l-layout_select_win_gray');});
						
						if(!opt.winOptions.close){
							opt.winOptions.close = function(){
								var operKey = opt.operKey || '__sw_oper';
								var dataKey = opt.dataKey || '__sw_data';
								var oper = art.dialog.data(operKey);
								if(oper=='ok' || oper=='OK'){
									var data = art.dialog.data(dataKey);
									if(data){
										swThis._id.val(data[opt.dataIdField||'id']);
										swThis._txt.val(data[opt.dataTextField||'text']);
										swThis._txt.attr('title', data[opt.dataTextField||'text']);
									}
								}
								art.dialog.data(operKey,null);
								art.dialog.data(dataKey,null);
							};
						}
						this._txt.click(function(){
							var url = opt.winOptions.url,
								value = encodeURIComponent(swThis._id.val()),
								pa = [{name:opt._field, value:value}],
								dataParam = opt.dataKey || '__sw_data';
							if(opt._field != dataParam){
								pa.push({name:dataParam, value:value});
							}
							url = g._mergeUrlParam(url, false, false, pa);
							art.dialog.open(url, opt.winOptions);
						});
					};
					this.getValue=function(){
						return this._id.val();
					};
					this.getText=function(){
						return this._txt.val();
					};
					this.reset=function(){
						this._txt._setValue(opt.initText||'');
						this._id.val(opt.initValue||'');
					};
					this.destroy=function(){
						if(this._ligerTxt){ this._ligerTxt.destroy(); }
					};
					
					this.init();
				};
				var p2 = {operKey:__param.operkey, dataKey:__param.datakey, dataIdField:__param.dataIdField, dataTextField:__param.dataTextField};
				p2._field = s.field;
				p2._idId = fieldHead +s.field;
				p2._idObj = $('#'+p2._idId, formObj);
				p2._txtId = fieldHead +s.field+'_txt';
				p2._txtObj = $('#'+p2._txtId, formObj);
				
				if(_spa && _spa.value){
					p2._idObj.val(_spa.value);
					p2._txtObj.val(_spa.text);
				}
				
				p2.txtOptions = {width: defaultWidth};
				$.extend(p2.txtOptions, __param.txtOptions);
				if(g._notEmpty(s.width))
				{
					p2.txtOptions.width = parseInt(s.width);
				}
				p2.winOptions = {
						id: 'ART_DIALOG_WINDOW_ID_SELECT_WIN_'+s.field,
						title: '请选择',
						width: 600,
						height: 350,
						fixed: true,
						lock: true,
						resize: false,
						opacity: 0.1,
						url: null,
						close: null
					};
				$.extend(p2.winOptions, __param.winOptions);
				//回调方法
				if(typeof p2.winOptions.close == 'string'){
					p2.winOptions.close = $.trim(p2.winOptions.close);
					if(p2.winOptions.close.length>5 && p2.winOptions.close.substr(0,5)=='func:')
					{
						var func = p2.winOptions.close.substr(5);
						p2.winOptions.close = eval("(false || "+func+")");
					}else{
						p2.winOptions.close = null;
					}
				}
				searchForm[s.field] = new _SW(p2);
			}
			else if(s.type=='date')
			{
				var p2 = {};
				$.extend(p2, {width: defaultWidth}, __param);
				if(_spa && _spa.value){
					p2.initValue = _spa.value;
				}else if(s.initValue){
					if(s.initValue === 'NOW'){
						p2.initValue = formatDate(new Date(), p2.format || (p2.showTime ? 'yyyy-MM-dd HH:mm':'yyyy-MM-dd'));
					}
					else if((/^NOW[+-]\d+$/g).test(s.initValue)){
						var _s1 = parseInt(s.initValue.substr(3));
						var date = new Date((new Date()).getTime() + _s1*1000);
						p2.initValue = formatDate(date, p2.format || (p2.showTime ? 'yyyy-MM-dd HH:mm':'yyyy-MM-dd'));
					}
					else{
						p2.initValue = s.initValue;
					}
				}
				if(g._notEmpty(s.width))
				{
					p2.width = parseInt(s.width);
				}
				if($.ligerui.get(fieldHead +s.field))
				{
					$.ligerui.remove(fieldHead +s.field);
				}
				var de = $('#'+fieldHead +s.field, formObj).ligerDateEditor(p2);
				searchForm[s.field] = de;
			}
			else if(s.type=='button')
			{
				var b = $('#'+fieldHead +s.field, formObj);
				b.data('configData', s);
				b.click(function(e){
					var d = $(this).data('configData');
					var funcname = "" + d.options;
					if(typeof(eval('('+funcname+')')) == 'function')
					{
						var parms = g.getSearchParams(false);
						eval('('+funcname+')').call(g, d, parms);
					}
					$(this).blur();
				});
			}
			else
			{
				var p2 = {};
				$.extend(p2, {width: defaultWidth}, __param);
				if(g._notEmpty(s.width))
				{
					p2.width = parseInt(s.width);
				}
				if($.ligerui.get(fieldHead +s.field))
				{
					$.ligerui.remove(fieldHead +s.field);
				}
				var tb = $('#'+fieldHead +s.field, formObj).ligerTextBox(p2);
				
				if(_spa && _spa.value){
					tb._setValue(_spa.value);
				}else if(s.initValue){
					tb._setValue(s.initValue);
				}
				searchForm[s.field] = tb;
			}
		},
		//创建搜索表单
		_createSearchForm: function(opt){
			var g = this, p = this.options;
			g.searchParams = [];
			
			//将需要隐藏的项目删除
			if(!opt.searches || !opt.searches.searchList){
				g.searches = null;
				g.searchForm = null;
				return;
			}
			var optSearchesList = opt.searches.searchList;
			g._filterHidein(optSearchesList);
			if(!optSearchesList || optSearchesList.length==0){
				g.searches = null;
				g.searchForm = null;
				return;
			}
			var searches = g.searches = opt.searches;
			var html = [];
			html.push('<div class="search search_border2 search_0">');
			html.push('<div class="f_row f_row2">');
			for(var j=0; j<optSearchesList.length;j++){
				var s = optSearchesList[j];
				if(s.type=='newline')
				{
					html.push('</div>');
					lines ++;
					html.push('<div class="f_row"');
					if(searchesList.length>1 && lines>0)
					{
						html.push(' style="margin-left:20px;"');
					}
					html.push('>');
					continue;
				}
				if(s.type!='button')
				{
					if(s.label){
						html.push('<div class="f_label" style="'+(s.labelstyle||'')+'" s-field="'+s.field+'-label">'+s.label+'：</div>');
					}
					html.push('<div class="f_item">');
					if(s.type=='select')
					{
						html.push('<input type="text" id="center_s_0_'+s.field+'_txt" s-field="'+s.field+'-txt" /><input type="hidden" id="center_s_0_'+s.field+'" s-field="'+s.field+'" />');
					}
					else if(s.type=='select-win')
					{
						html.push('<input type="text" id="center_s_0_'+s.field+'_txt" s-field="'+s.field+'-txt" /><input type="hidden" id="center_s_0_'+s.field+'" s-field="'+s.field+'" />');
					}
					else if(s.type=='date')
					{
						html.push('<input type="text" id="center_s_0_'+s.field+'" s-field="'+s.field+'" />');
					}
					else
					{
						html.push('<input type="text" id="center_s_0_'+s.field+'" s-field="'+s.field+'" placeholder="'+(s.placeholder||'')+'" />');
					}
					html.push('</div>');
				}
				else
				{
					html.push('<div class="f_item f_btns"><input type="button" value="'+s.label+'" style="'+(s.labelstyle||'')+'" class="l-button oper-btn" id="center_s_0_'+s.field+'" /></div>');
				}
			}
			html.push('<div class="f_item f_btns" style="margin-left:10px"><input type="button" value="搜索" class="l-button" id="center_s_0_searchbtn" /></div>');
			html.push('</div>');
			html.push('</div>');
			
			g.center.maincontainer.append(html.join(''));
			g.center.searchform = $(".search_0", g.center.maincontainer);
			g.center.searchbtn = $("#center_s_0_searchbtn", g.center.searchform);
			
			//表单样式
			g.searchForm = {};
			for(var j=0; j<optSearchesList.length;j++)
			{
				var s = optSearchesList[j];
				if(s.type=='newline')
				{
					continue;
				}
				var __param = {};
				s.options = s.options || '';
				if($.trim(s.options).length>0)
				{
					s.options = g._getUrl(s.options);
					__param = eval("("+$.trim(s.options)+")");
				}
				//_createSearchItems: function(searchItem, __param, fieldHead, defaultWidth, formObj, searchForm)
				g._createSearchItems(s, __param, 'center_s_0_', 200, g.center.searchform, g.searchForm);
			}
			//计算最小宽度
			var _minwidth = 0;
			var f_rows = $('> .f_row', g.center.searchform);
			f_rows.each(function(i1, n1){
				var f_row = $(n1);
				var _w = 0;
				var divs = $('> div', f_row);
				divs.each(function(i2, n2){
					_w += $(n2).width();
					_w += parseInt($(n2).css('marginLeft'));
				});
				if(_w > _minwidth){
					_minwidth = _w;
				}
			});
			_minwidth += 50;//修正
			g.center.maincontainer.css("min-width", _minwidth+"px");
			
			//搜索事件绑定
			g.center.searchbtn.click(function(e){
				if(g.center.tablegrid)
				{
					var parms = [];
					var _lfield = (g.globalObj.leftdata!=null)?g.globalObj.leftdata.field:null;
					if(g._notEmpty(_lfield) && _lfield!='leftdata' && g._notEmpty(g.globalParam.leftdata))
					{
						parms.push({name:_lfield, value:g.globalParam.leftdata});
					}
					g.searchParams = g.getSearchParams(false);
					for(var j in g.searchParams){
						var sp = g.searchParams[j];
						parms.push({name:sp.name, value:sp.value});
					}
					var gparam = g._getGlobalParam();
					for(var key in gparam)
					{
						parms.push({name:key, value:gparam[key]});
					}
					g.center.tablegrid.set('newPage', 1);
					g.center.tablegrid.set({parms: parms});
					g.center.tablegrid.loadData(true);
				}
				$(this).blur();
			});
			g.center.searchformIndex = 0;
		},
		_setRefreshTimer: function(autorefresh){
			var g = this;
			if(g._timerid){
				window.clearInterval(g._timerid);
				g._timerid = null;
			}
			if(g._isEmpty(autorefresh))return;
			if(!g.center.tablegrid)return;
			if($.isNumeric(autorefresh)){
				autorefresh = parseInt(autorefresh);
				if(autorefresh > 0){
					g.center.tablegrid.set('showLoading', false);
					g._timerid = window.setInterval(function(){g._refreshTablegrid();}, autorefresh * 1000);
				}
			}else{
				autorefresh = $.trim(g._getUrl(autorefresh));
				if(autorefresh.length>5 && autorefresh.substr(0,5)=='func:')
				{
					var func = autorefresh.substr(5);
					func = eval("(false || "+func+")");
					func.call(g, g.center.tablegrid);
				}
			}
		},
		_refreshTablegrid: function(){
			var g = this;
			if(!g.center.tablegrid)return;
			g.center.tablegrid.loadData(true);
		},
		//创建中间表格
		createCenterTable: function(opt, reclick){
			var g = this, p = this.options;
			g._emptyCenter();
			//搜索
			g._createSearchForm(opt);
			
			//表格
			g.center.maincontainer.append('<div id="center_tablegridout"><div id="center_tablegridcon"></div></div>');
			g.center.tablegridout = $("#center_tablegridout", g.center.maincontainer);
			g.center.tablegridcon = $("#center_tablegridcon", g.center.maincontainer);
			var table = g.globalObj.centerConf = opt.table;
			
			var p2 = g._createCenterTableOpts(table.idfield, table.pagesize, table.checkbox, table.pager, table.url, table);
			
			//如果需要隐藏右侧部分
			if(opt.right && g._pipeStrToMap(opt.right.hidein)[g.globalParam.datatype]){
				opt.right.type = 'hide';//隐藏
			}
			if(!opt.right){
				opt.right = {type:'hide'};
			}
			if(p2.toolbar){
				p2.dynamicToolbar = true;
				p2.dynamicToolbarRender = function(selectedNumber, selected)
				{
					g._setTableOper(this, selectedNumber, selected);
				};
			}
			
			//条件
			var _lfield = (g.globalObj.leftdata!=null)?g.globalObj.leftdata.field:null;
			if(g._notEmpty(_lfield) && _lfield!='leftdata' && g._notEmpty(g.globalParam.leftdata))
			{
				p2.parms.push({name:_lfield, value:g.globalParam.leftdata});
			}
			var gparam = g._getGlobalParam();
			for(var key in gparam)
			{
				p2.parms.push({name:key, value:gparam[key]});
			}
			if(g.searchParams && g.searchParams.length>0){
				for(var si in g.searchParams){
					var sp = g.searchParams[si];
					p2.parms.push({name:sp.name, value:sp.value});
				}
			}
			//大小调整
			g._onResize();
			
			//ligerGrid
			if($.ligerui.get(g.center.tablegridcon.attr("id")))
			{
				
				$.ligerui.remove(g.center.tablegridcon.attr("id"));
			}
			g.center.tablegrid = g.center.tablegridcon.ligerGrid(p2);
			
			//右侧
			g._createRightPanel(opt);
			
			g._setRefreshTimer(table.autorefresh);
		},
		_createCenterTableOpts: function(idfield, pagesize, checkbox, pager, url, tableOptions){
			var g = this, p = this.options;
			var p2 = {
				parms: [],
				height: '99.5%',
				inWindow: false,
				pageSizeOptions: [15, 20, 30, 50, 100],
				pageSize: p.defaultPageSize,
				columnWidth: 125,
				checkbox:true,
				allowHideColumn: false,
				root: "rows",
				record: "total",
				dataAction : 'server',
				rownumbers:true,
				idfield: idfield
			};
			tableOptions.options = tableOptions.options || '';
			if($.trim(tableOptions.options).length>0)
			{
				tableOptions.options = g._getUrl(tableOptions.options);
				tableOptions.options = eval("("+$.trim(tableOptions.options)+")");
				var __options = {};
				$.extend(__options, p2, tableOptions.options);
				p2 = __options;
			}
			delete tableOptions['options'];
			
			if(g._notEmpty(pagesize))
			{
				if(pagesize == '${defaultPageSize}')
				{
					pagesize = p.defaultPageSize;
				}
				p2.pageSize = parseInt(pagesize);
			}
			if($.inArray(p2.pageSize, p2.pageSizeOptions) == -1){
				p2.pageSizeOptions.push(p2.pageSize);
			}
			if(g._notEmpty(checkbox))
			{
				p2.checkbox = (checkbox=='true');
			}
			if(g._notEmpty(tableOptions.rownumbers))
			{
				p2.rownumbers = (tableOptions.rownumbers=='true');
			}
			if(g._notEmpty(pager))
			{
				p2.usePager = (pager=='true');
			}
			if(g._notEmpty(tableOptions.sort))
			{
				p2.enabledSort = (tableOptions.sort=='true');
			}
			if(g._notEmpty(tableOptions.rowAttrRender))
			{
				var _render = $.trim(g._getUrl(tableOptions.rowAttrRender));
				p2.rowAttrRender = eval("(false || "+_render+")");
			}
			p2.url = g._getUrl(url);
			p2.url = g._parseSysParam(p2.url);
			
			//表格数据
			var columns = [];
			g._filterHidein(tableOptions.columns);
			for(var i in tableOptions.columns)
			{
				var column = tableOptions.columns[i];
				
				if(column.loop && /^\[(\d+)-(\d+)\]$/gi.test(column.loop)){
					var rs = /^\[(\d+)-(\d+)\]$/gi.exec(column.loop),
						start = parseInt(rs[1]), 
						end = parseInt(rs[2]);
					for(; start<=end; start++){
						var _c = jQuery.extend(true, {}, column);
						_c.display = _c.display.replace('[*]', String(start));
						_c.name = _c.name.replace('[*]', String(start));
						
						g._parseColumn(_c, tableOptions);
						delete _c['subColumns'];
						
						columns.push(_c);
					}
				}else{
					g._parseColumn(column, tableOptions);
					delete column['subColumns'];
					
					columns.push(column);
				}
			}
			p2.columns = columns;
			
			//处理操作链接
			if(tableOptions.operlink == true){
				delete tableOptions['operlink'];
				
				p2.onAfterShowData = function(data){
					var _tb = this;
					var links = $('a.operlink', _tb.gridview);
					links.bind("click.layout3", {table : _tb}, function(event){
						var link = $(this);
						var tb = event.data.table;
						var id = link.attr('id').split('|');
						
						var record = tb.getRow(parseInt(id[1]));
						var col = tb.getColumn(parseInt(id[2]));
						var ritm = col.operItems[parseInt(id[3])];
						
						var idParam = {name: g.globalObj.centerConf.idfield, value: record[g.globalObj.centerConf.idfield]};
						
						
						if(ritm.model=='window')
						{
							g._operModelWindow(ritm, false, [idParam]);
						}
						else if(ritm.model=='dialog')
						{
							g._operModelDialog(ritm, false, [idParam]);
						}
						else if(ritm.model=='popup')
						{
							g._operModelPopupWindow(ritm, false, [idParam]);
						}
						else if(ritm.model=='func')
						{
							var funcname = g._getUrl(ritm.url);
							if(typeof(eval('('+funcname+')')) == 'function')
							{
								eval('('+funcname+')').call(g, ritm, record, g.center.tablegrid);
							}
							else
							{
								alert("错误[005]：方法["+funcname+"]未定义.");
							}
						}
						//打开一个新窗口
						else if(ritm.model=='url')
						{
							var url = g._getUrl(ritm.url);
							url = g._mergeUrlParam(url, ritm.uiparam==='false', false);
							url = g._parseSysParam(url);
							url = g._parseFields(record, url);
							window.open(url, '_blank');
						}
						return false;
					});
				};
				
			}
			
			//表格操作工具条
			if(tableOptions.toolbar && !g._pipeStrToMap(tableOptions.toolbar.hidein)[g.globalParam.datatype]
					&& tableOptions.toolbar.operItems && tableOptions.toolbar.operItems.length){
				var toolbar_items = [];
				g._filterHidein(tableOptions.toolbar.operItems);
				var ritems = tableOptions.toolbar.operItems;
				for(var i in ritems){
					var ritem = ritems[i];
					toolbar_items.push({line:true});
					var btnitm = {text: ritem.name, display: g._parseSysParam(ritem.display)};
					btnitm.img = g._getIconPath(ritem.icon);
					btnitm._ritm = ritem;
					btnitm.click = function(itm){
						var ritm = itm._ritm;
						
						if(ritm.model=='window')
						{
							g._operModelWindow(ritm, true);
						}
						else if(ritm.model=='dialog')
						{
							g._operModelDialog(ritm, true);
						}
						else if(ritm.model=='popup')
						{
							g._operModelPopupWindow(ritm, true);
						}
						else if(ritm.model=='func')
						{
							var funcname = g._getUrl(ritm.url);
							if(typeof(eval('('+funcname+')')) == 'function')
							{
								eval('('+funcname+')').call(g, ritm, g.center.tablegrid);
							}
							else
							{
								alert("错误[005]：方法["+funcname+"]未定义.");
							}
						}
						//打开一个新窗口
						else if(ritm.model=='url')
						{
							var url = g._getUrl(ritm.url);
							url = g._mergeUrlParam(url, ritm.uiparam==='false', ritm.centerdataid);
							url = g._parseSysParam(url);
							window.open(url, '_blank');
						}
					};
					toolbar_items.push(btnitm);
				}
				if(toolbar_items.length>0){
					toolbar_items.push({line:true});
					p2.toolbar = {items : toolbar_items, operItemEffect: p.operItemEffect};
				}else{
					p2.toolbar = null;
				}
			}else{
				p2.toolbar = null;
			}
			
			//明细列
			if(tableOptions.detail && tableOptions.detail.render){
				var d = tableOptions.detail;
				p2.detail = {};
				if(g._notEmpty(d.height))
				{
					p2.detail.height = parseInt(d.height);
				}
				d.render = g._getUrl(d.render);
				
				if(d.render.length>5 && d.render.substr(0,5)=='func:')
				{
					var func = d.render.substr(5);
					p2.detail.func = eval("(false || "+func+")");
				}
				else if(d.render.length>5 && d.render.substr(0,5)=='temp:')
				{
					p2.detail._temp = d.render.substr(5);
					p2.detail.func = function(record, pdetail){
						return g._parseFields(record, pdetail._temp);
					};
				}
				else if(d.render.length>5 && d.render.substr(0,5)=='ajax:')
				{
					var ajaxParam = d.render.substr(5);
					ajaxParam = eval("("+ajaxParam+")");
					ajaxParam.loading = false;
					if(!ajaxParam.data){
						ajaxParam.data = {};
					}
					p2.detail._idfield = idfield;
					p2.detail._ajaxParam = ajaxParam;
				}
				else
				{
					p2.detail.field = d.render;
				}
				p2.detail.onShowDetail = function(record, detailPanel, callback, pdetail){
					$(detailPanel).addClass('l-grid-detailpanel-inner-margin');
					if(pdetail.func){
						var _text = pdetail.func(record, pdetail);
						$(detailPanel).html(_text);
					}
					else if(pdetail._ajaxParam)
					{
						var _idfield = pdetail._idfield;
						var _ajaxParam = pdetail._ajaxParam;
						_ajaxParam.data = {};
						_ajaxParam.data[_idfield] = record[_idfield];
						g.getAjaxData(_ajaxParam.url, _ajaxParam, function(data, _con){
							_con.html(data);
						}, $(detailPanel));
					}
					else if(p2.detail.field)
					{
						$(detailPanel).html(record[p2.detail.field]);
					}
				};
			}else{
				p2.detail = null;
			}
			p2.layout3 = g;
			return p2;
		},
		//解析表格列配置
		_parseColumn: function(column, tableOptions)
		{
			var g = this, p = this.options;
			//宽度
			if(g._notEmpty(column.width)){
				column.width = parseInt(column.width);
			}else{
				delete column['width'];
			}
			//对齐
			if(g._isEmpty(column.align)){
				delete column['align'];
			}
			//固定
			if(g._notEmpty(column.frozen)){
				column.frozen = (column.frozen=='true');
			}else{
				delete column['frozen'];
			}
			//排序
			if(g._notEmpty(column.sort)){
				column.isSort = (column.sort=='true');
			}
			delete column['sort'];
			//数据类型
			if(g._isEmpty(column.type)){
				delete column['type'];
			}
			//数据格式化
			if(g._isEmpty(column.format)){
				delete column['format'];
			}
			//空值替换文本
			if(g._isEmpty(column.empty)){
				delete column['empty'];
			}
			//动态的
			if(g._notEmpty(column.dynamic)){
				column.dynamic = (column.dynamic==='true');
			}else{
				delete column['dynamic'];
			}
			//统计行
			if(g._notEmpty(column.totalSummary))
			{
				var totalSummary = $.trim(column.totalSummary);
				if(totalSummary.length>5 && totalSummary.substr(0,5)=='func:')
				{
					var func = totalSummary.substr(5);
					column.totalSummaryFunc = eval("(false || "+func+")");
					column.totalSummary = {};
					column.totalSummary.render = function(suminf, col, data){
						var t = col.totalSummaryFunc.call(this, suminf, col, data, g);
						return t;
					};
				}
				else if(totalSummary.length>5 && totalSummary.substr(0,5)=='temp:')
				{
					var temp = totalSummary.substr(5);
					column.totalSummaryTemp = temp;
					column.totalSummary = {};
					column.totalSummary.render = function(suminf, col, data){
						var _text = col.totalSummaryTemp.replace(/#\{(.+?)}/g, function(word, key){
			        		try{
			        			var _val = new Function("obj", "return obj."+key+";")(suminf);
			        			if(typeof _val === 'undefined' || _val === null){
			        				return "";
			        			}
			        			return ''+_val;
			        		}catch(e){
			        			return 'null';
			        		}
			        	});
			        	return ("<div>"+_text +"</div>").replace('\\n', '</div><div>');
					};
				}
				else{
					column.totalSummary = {type:totalSummary};
				}
			}
			//操作项列
			else if(column.type == 'operlink'){
				delete column['type'];
				delete column['render'];
				tableOptions.operlink = true;
				//操作链接处理
				g._filterHidein(column.operItems);
				if(column.operItems && column.operItems.length>0)
				{
					column.render = function(record, rowindex, value, col)
					{
						var operItems = col.operItems;
						var html = [];
						for(var i=0; i<operItems.length; i++)
						{
							var ritm = operItems[i];
							if(i>0){ html.push('&nbsp;&nbsp;'); }
							html.push('<a id="operlink|'+rowindex+'|'+col.columnindex+'|'+i
									+'" href="javascript:;" class="operlink" title="'+(ritm.title||ritm.name)+'">');
							if(g._isEmpty(ritm.icon)){
								html.push(ritm.name);
							}else{
								html.push('<img src="'+p.iconpath+'/'+ritm.icon+'" alt="'+ritm.name+'" />');
							}
							html.push('</a>');
						}
						return html.join('');
					};
				}
				//没有相关操作权限时
				else
				{
					column.render = function(record, rowindex, value, col)
					{
						return '<span style="color:#999;">'+p.noPermission+'<span>';
					};
				}
				
			}
			//自定义渲染器
			else if(g._notEmpty(column.render))
			{
				column.render = $.trim(g._getUrl(column.render));
				if(column.render.length>5 && column.render.substr(0,5)=='func:')
				{
					var func = column.render.substr(5);
					column.renderFunc = eval("(false || "+func+")");
					column.render = function(record, rowindex, value, col)
					{
						var t = col.renderFunc.call(this, record, rowindex, value, col, g);
						return t;
					};
				}
				else if(column.render.length>5 && column.render.substr(0,5)=='temp:')
				{
					var _rendertemp = column.render.substr(5);
					column.renderFunc = function(record){
						return g._parseFields(record, _rendertemp);
					};
					column.render = function(record, rowindex, value, col)
					{
						return col.renderFunc.call(this, record);
					};
				}
				else
				{
					column.datamap = eval("("+column.render+")");
					column.render = function(record, rowindex, value, col){
						return col.datamap[String(value)] || value;
					};
				}
			}
			else
			{
				delete column['render'];
			}
		},
		//创建右侧面板
		_createRightPanel: function(opt)
		{
			var g = this, p = this.options;
			if(!opt || !opt.right){
				g._hideRight();
				return;
			}
			right = opt.right;
			g.globalObj.rightconf = right;
			if(right.type=='hide')
			{
				g._hideRight();
				return;
			}
			g._showRight();
			var ww = 0;
			if(g._notEmpty(right.width))
			{
				ww = parseInt(right.width) || 0;
			}
			g._setRightWidth(ww);
			
			g.right.tabIndex = 0;
			g.right.tabName = g._parseSysParam(right.name);
			g.setRightTitle(g._parseSysParam(right.title || right.name));
			var tabc = g.right.content;
			tabc.show();
			tabc.empty();
			tabc.css('overflow', 'hidden');
			g._emptyRight(0);
			
			if(right.type=='page'){
				var url = g._getUrl(right.url);
				url = g._mergeUrlParam(url, right.uiparam==='false', false);
				url = g._parseSysParam(url);
				if(right.scroll=='true')
				{
					tabc.css('overflow', 'auto');
				}
				tabc.load(url);
			}
			else if(right.type=='iframe')//使用iframe加载页面
			{
				var rifm = g.right.iframe = $('<iframe id="rightiframe" name="rightiframe" frameborder="0" class="l-layout-sideiframe"></iframe>');
				if(right.scroll=='true')
				{
					rifm.css('overflow', 'auto');
				}
				else
				{
					rifm.css('overflow', 'hidden');
				}
				tabc.append(rifm);
				var src = g._getUrl(right.url);
				src = g._mergeUrlParam(src, right.uiparam==='false', false);
				src = g._parseSysParam(src);
				rifm.attr("src", src).unbind('load.layout3').bind('load.layout3', function (){
					rifm.unbind('load.layout3');
				});
			}
			else{
				alert('RIGHT[001]类型错误:'+right.type);
			}
			
		},
		//操作菜单的model=window模式
		_operModelWindow: function(ritm, useCenterData, paramList){
			var g = this, p = this.options;
			if(useCenterData){
				if(ritm.display!='fix' && g._isEmpty(g.globalParam.centerdata))
				{
					top.art.dialog({content:'<b>至少选择一条信息</b>', icon:'error', ok:true, lock:true,resize:false, opacity:0.1});
					return;
				}
			}
			var url = g._getUrl(ritm.url);
			url = g._mergeUrlParam(url, ritm.uiparam==='false', useCenterData, paramList);
			url = g._parseSysParam(url);
			
			//g._orgCenterTitle = g.getCenterTitle();
			//g.setCenterTitle(g._parseSysParam(ritm.title||ritm.name));
			
			g.center.formiframe.show();
			g.center.loading.show();
			g.center.formiframe.data("itemCfg", ritm);
			g.center.formiframe.attr("src", url).unbind('load.layout3').bind('load.layout3', function (){
				g.center.loading.hide();
				g.center.formiframe.unbind('load.layout3');
				if(!g._isLocalUrl(g.center.formiframe[0].src))return;
				var icwin = g.center.formiframe[0].contentWindow;
				if(!icwin)return;
				if(typeof(icwin[g.globalFuncName.formChanged])=='function')
				{
					g.globalCallFunc.formChanged = icwin[g.globalFuncName.formChanged];
				}
			});
		},
		//打开表单界面
		//opts:{url:'',title:'',refresh:''}
		//params:[{name:'',value:''}]
		openForm: function(opts, params){
			var g = this, p = this.options;
			g._operModelWindow(opts, false, params);
		},
		isFormOpen: function(){
			var g = this, p = this.options;
			return g.center.formiframe && g.center.formiframe.is(":visible");
		},
		//关闭g.center.formiframe
		//参数succeeded：操作成功传入true，执行刷新等操作
		closeForm: function(succeeded){
			var g = this, p = this.options;
			if(g.center.formiframe && g.center.formiframe.is(":visible")){
				if(g.globalCallFunc.formChanged && g.globalCallFunc.formChanged.call(g)){
					if(confirm('内容还未保存，确定关闭吗？')){
						var itemCfg = g.center.formiframe.data("itemCfg");
						g._emptyFormiframe();
						if(succeeded){
							var _refresh = itemCfg.refresh;
							g.refreshData(_refresh);
						}
					}else{
						return false;
					}
				}else{
					var itemCfg = g.center.formiframe.data("itemCfg");
					g._emptyFormiframe();
					if(succeeded){
						var _refresh = itemCfg.refresh;
						g.refreshData(_refresh);
					}
				}
			}
			return true;
		},
		refreshData: function(refresh){
			var g = this, p = this.options;
			if(!refresh){
				if(g.center.tablegrid){
					g.center.tablegrid.loadData();
				}
			}else{
				if(refresh=='all' || refresh=='table' || refresh===true)
				{
					if(g.center.tablegrid){
						g.center.tablegrid.loadData();
					}
				}
				if(refresh=='all' || refresh=='left' || refresh===true)
				{
					g.reloadLeftTree(g.globalParam.leftdata);
				}
			}
		},
		//操作菜单的model=dialog模式
		_operModelDialog: function(ritm, useCenterData, paramList){
			var g = this, p = this.options;
			if(useCenterData){
				if(ritm.display!='fix' && g._isEmpty(g.globalParam.centerdata))
				{
					top.art.dialog({content:'<b>至少选择一条信息</b>', icon:'error', ok:true, lock:true,resize:false, opacity:0.1});
					return;
				}
			}
			top.art.dialog({
				id: 'Confirm',
				icon: 'question',
				title : g._parseSysParam(ritm.title||ritm.name),
				fixed:true,
				lock:true,
				resize:false,
				opacity:0.1,
				content:'<p style="line-height:20px"><b>'+g._parseSysParam(ritm.confirm)+'<b></p>',
				ok: function (here) {
					var url = g._getUrl(ritm.url);
					url = g._mergeUrlParam(url, true, useCenterData, paramList);
					url = g._parseSysParam(url);
					var params = {};
					if(ritm.uiparam==='false')
					{
						//全局参数
						params = g._getGlobalParam();
					}
					$.post(url, params, function(data){
						if(data && typeof(data)=='string'){
	        				data = $.parseJSON($.trim(data));
	        			}
						if(!UiUtil.hasErrors(data, function(){}))
						{
							var _msg = ritm.succeed.replace(/\{(.+?)}/g, function(word, key){
				        		if(key.indexOf('.') == -1){
				        			return !!data[key] ? data[key] : '';
								}else{
									try{
										return new Function("data", "return data."+key+";")(data) || '';
									}catch(e){
										return 'null';
									}
								}
							});
							jSuccess(_msg,{
								clickOverlay: true,
								TopOffset: 80,
								onClosed: function(){
									var _refresh = ritm.refresh;
									g.refreshData(_refresh);
								}
							});//jSuccess
						}
					}, 'json');//$.post
				},//ok:
				cancel:true
			});//top.art.dialog
		},
		//操作菜单的model=popup模式
		_operModelPopupWindow: function(ritm, useCenterData, paramList){
			var g = this, p = this.options;
			if(useCenterData){
				if(ritm.display!='fix' && g._isEmpty(g.globalParam.centerdata))
				{
					top.art.dialog({content:'<b>至少选择一条信息</b>', icon:'error', ok:true, lock:true,resize:false, opacity:0.1});
					return;
				}
			}
			var url = g._getUrl(ritm.url);
			url = g._mergeUrlParam(url, ritm.uiparam==='false', useCenterData, paramList);
			url = g._parseSysParam(url);
			
			art.dialog.removeData('refresh');
			art.dialog.open(url, {
				title : g._parseSysParam(ritm.title||ritm.name),
				width : parseInt(ritm.width),
				height : parseInt(ritm.height),
				id : 'LAYOUT3_ART_DIALOG_WINDOW_ID_'+ritm.code,
				fixed : true,
				lock  : true,
				resize: false,
				opacity: 0.1,	// 透明度
				init: function(iwin){
					if(!iwin)return;
					if(typeof(iwin[g.globalFuncName.layoutInit])=='function')
					{
						iwin[g.globalFuncName.layoutInit].call(g, g);
					}
				},
				close: function(){
					var _refresh = ritm.refresh;
					g.refreshData(_refresh);
				}
			});
		},
		//右侧操作项的显示和隐藏
		_setTableOper: function(grid, selectedNumber, selected){
			var g = this, p = this.options;
			if(!g.center.tablegrid)return;
			var len = g.center.tablegrid.getSelecteds().length;
			if(g.center.tablegrid.toolbarManager){
				g.center.tablegrid.toolbarManager.setDisplay(len);
			}
			g.globalParam.centerdata = '';
			g.globalObj.centerdata = [];
			if(len>0)
			{
				var rows = g.center.tablegrid.getSelecteds();
				var ids = [];
				for(var i in rows)
				{
					ids.push(rows[i][g.globalObj.centerConf.idfield]);
				}
				g.globalObj.centerdata = rows;
				g.globalParam.centerdata = ids.join(';');
			}
		},
		//重新加载右侧
		_reloadRight: function(reclick)
		{
			var g = this, p = this.options;
			if(!reclick)return false;
			
			var right = g.globalObj.rightconf;
			if(!right || right.type=='hide'){
				g._hideRight();
				return false;
			}
			g._createRightPanel({right: right});
			return true;
		},
		_emptyLeft: function()
		{
			var g = this;
			g.left.ZTree = null;
			if(g.left.ZTreeObj)
			{
				g.left.ZTreeObj.destroy();
			}
			g.left.ZTreeObj = null;
			g.left.accordioncon = null;
			g.left.accordion = null;
			g.left.content.empty();
		},
		_emptyCenter: function(){
			var g = this;
			g.center.maincontainer.css("min-width", "auto");
			g.center.maincontainer.empty();
			g.center.mainiframe.attr("src", "about:blank");
			g._emptyFormiframe();
			g.center.loading.hide();
			g.center.tablegridout = null;
			if(g.center.tablegridcon){
				g.center.tablegridcon.empty();
			}
			g.center.tablegridcon = null;
			if(g.center.tablegrid){
				g.center.tablegrid.destroy();
			}
			g.center.tablegrid = null;
			g.center.searchform =null;
			g.center.searchbtn = null;
			
			g._deleteFunc(window, g.globalFuncName.uiCall);
			g.globalCallFunc.uiCall = null;
			g.globalCallFunc.searchCall = null;
		},
		_emptyFormiframe: function(){
			var g = this;
			if(g.center.formiframe){
				g.center.formiframe.hide();
				g.center.formiframe.attr("src", "about:blank");
				g.center.formiframe.removeData("itemCfg");
				//g.setCenterTitle(g._orgCenterTitle);
				g._deleteFunc(window, g.globalFuncName.formChanged);
				g.globalCallFunc.formChanged = null;
			}
		},
		_emptyRight: function(tabIndex)
		{
			var g = this;
			g.right.content.empty();
		},
		
        //设置左侧标题
		setLeftTitle: function (title)
		{
			$(".l-layout-header-inner", this.left.header).html(title);
		},
		setCtabsTitle: function (title)
		{
			$(".l-layout-header-inner", this.ctabs.header).html(title);
		},
		getCenterTitle: function (){
			return this.center.header.inner.html();
		},
		setCenterTitle: function (title)
		{
			this.center.header.inner.html(title);
		},
		setRightTitle: function (title)
		{
			$(".l-layout-header-inner", this.right.header).html(title);
		},
		hideLeftTabsbar: function(){
			var g = this;
			if(g.left.tabsbar)
			{
				g.left.tabsbar.hide();
				g._onResize();
			}
		},
		showLeftTabsbar: function()
		{
			var g = this;
			if(g.left.tabsbar)
			{
				g.left.tabsbar.show();
				g._onResize();
			}
		},
		hideCenterTabsbar: function(){
			var g = this;
			if(g.ctabs)
			{
				g.ctabs.hide();
				g._onResize();
			}
		},
		showCenterTabsbar: function(){
			var g = this;
			if(g.ctabs)
			{
				g.ctabs.show();
				g._onResize();
			}
		},
        setLeftCollapse: function (isCollapse)
        {
            var g = this, p = this.options;
            if (!g.left) return false;
            g.isLeftCollapse = isCollapse;
            if (g.isLeftCollapse)
            {
                g.leftCollapse.show();
                if(g.leftDropHandle)
                {
                	g.leftDropHandle.hide();
                }
                g.left.hide();
            }
            else
            {
                g.leftCollapse.hide();
                if(g.leftDropHandle)
                {
                	g.leftDropHandle.show();
                }
                g.left.show();
            }
            g._onResize();
        },
        setRightCollapse: function (isCollapse)
        {
            var g = this, p = this.options;
            if (!g.right) return false;
            g.isRightCollapse = isCollapse;
            g._onResize();
            if (g.isRightCollapse)
            {
                g.rightCollapse.show();
                if(g.rightDropHandle)
                {
                	g.rightDropHandle.hide();
                }
                g.right.hide();
            }
            else
            {
                g.rightCollapse.hide();
                if(g.rightDropHandle)
                {
                	g.rightDropHandle.show();
                }
                g.right.show();
            }
            g._onResize();
        },
		_hideRight: function(){
			var g = this;
			if(g.rightCollapse)
			{
				g.rightCollapse.hide();
			}
			if(g.right){
				g.right.hide();
				if(g.rightDropHandle)
				{
					g.rightDropHandle.hide();
				}
			}
			g.righthided = true;
			g._onResize();
		},
		_showRight: function(){
			var g = this;
			if(g.isRightCollapse){
				g.rightCollapse.show();
				if(g.rightDropHandle)
                {
                	g.rightDropHandle.hide();
                }
				g.right.hide();
			}else{
				g.rightCollapse.hide();
                if(g.rightDropHandle)
                {
                	g.rightDropHandle.show();
                }
                g.right.show();
			}
			g.righthided = false;
			g._onResize();
		},
		_setLeftWidth: function(width){
			var g = this, p = this.options;
			g.leftWidth = width || parseInt(p.leftWidth);
			if(g.left.width()!=g.leftWidth)
			{
                g.left.width(g.leftWidth);
                $(window).resize();
			}
		},
		_setCtabsWidth: function(width){
			var g = this, p = this.options;
			g.ctabsWidth = width || parseInt(p.ctabsWidth);
			if(g.ctabs.width()!=g.ctabsWidth)
			{
                g.ctabs.width(g.ctabsWidth);
                $(window).resize();
			}
		},
		_setRightWidth: function(width){
			var g = this, p = this.options;
			g.rightWidth = width || parseInt(p.rightWidth);
			if(g.right.width() != g.rightWidth)
			{
				g.right.width(g.rightWidth);
				$(window).resize();
			}
		},
        _bulid: function ()
        {
            var g = this, p = this.options;
			$("> .l-layout-left .l-layout-header,> .l-layout-right .l-layout-header", g.layout).hover(function ()
            {
                $(this).addClass("l-layout-header-over");
            }, function ()
            {
                $(this).removeClass("l-layout-header-over");

            });
			$(".l-layout-tbtn", g.layout).hover(function ()
            {
                $(this).addClass("l-layout-tbtn-over");
            }, function ()
            {
                $(this).removeClass("l-layout-tbtn-over");
            });
            $(".l-layout-header-toggle", g.layout).hover(function ()
            {
                $(this).addClass("l-layout-header-toggle-over");
            }, function ()
            {
                $(this).removeClass("l-layout-header-toggle-over");

            });
            $(".l-layout-header-toggle", g.left).click(function ()
            {
                g.setLeftCollapse(true);
            });
            $(".l-layout-header-toggle", g.right).click(function ()
            {
                g.setRightCollapse(true);
            });
            //set top
            g.middleTop = 0;
            if (g.top)
            {
                g.middleTop += g.top.height();
                g.middleTop += parseInt(g.top.css('borderTopWidth'));
                g.middleTop += parseInt(g.top.css('borderBottomWidth'));
                g.middleTop += p.space;
            }
            if (g.left)
            {
                g.left.css({ top: g.middleTop });
                g.leftCollapse.css({ top: g.middleTop });
            }
            if(g.ctabs){
            	g.ctabs.css({ top: g.middleTop });
            }
            if (g.center){
            	g.center.css({ top: g.middleTop });
            }
            if (g.right)
            {
                g.right.css({ top: g.middleTop });
                g.rightCollapse.css({ top: g.middleTop });
            }
            //set left
            if (g.left)
            {
            	g.left.css({ left: 0 });
            }
            g._onResize();
            g._onResize();
        },
        _setCollapse: function ()
        {
            var g = this, p = this.options;
            g.leftCollapse.hover(function ()
            {
                $(this).addClass("l-layout-collapse-left-over");
            }, function ()
            {
                $(this).removeClass("l-layout-collapse-left-over");
            });
            g.leftCollapse.toggle.hover(function ()
            {
                $(this).addClass("l-layout-collapse-left-toggle-over");
            }, function ()
            {
                $(this).removeClass("l-layout-collapse-left-toggle-over");
            });
            g.rightCollapse.hover(function ()
            {
                $(this).addClass("l-layout-collapse-right-over");
            }, function ()
            {
                $(this).removeClass("l-layout-collapse-right-over");
            });
            g.rightCollapse.toggle.hover(function ()
            {
                $(this).addClass("l-layout-collapse-right-toggle-over");
            }, function ()
            {
                $(this).removeClass("l-layout-collapse-right-toggle-over");
            });
            g.leftCollapse.toggle.click(function ()
            {
                g.setLeftCollapse(false);
            });
            g.rightCollapse.toggle.click(function ()
            {
                g.setRightCollapse(false);
            });
            if (g.left && g.isLeftCollapse)
            {
                g.leftCollapse.show();
                g.leftDropHandle && g.leftDropHandle.hide();
                g.left.hide();
            }
            if (g.right && g.isRightCollapse)
            {
                g.rightCollapse.show();
                g.rightDropHandle && g.rightDropHandle.hide();
                g.right.hide();
            }
        },
        _addDropHandle: function ()
        {
            var g = this, p = this.options;
            if (g.left && p.allowLeftResize)
            {
                g.leftDropHandle = $("<div class='l-layout-drophandle-left'></div>");
                g.layout.append(g.leftDropHandle);
                g.leftDropHandle && g.leftDropHandle.show();
                g.leftDropHandle.mousedown(function (e)
                {
                    g._start('leftresize', e);
                });
            }
            if (g.right && p.allowRightResize)
            {
                g.rightDropHandle = $("<div class='l-layout-drophandle-right'></div>");
                g.layout.append(g.rightDropHandle);
                g.rightDropHandle && g.rightDropHandle.show();
                g.rightDropHandle.mousedown(function (e)
                {
                    g._start('rightresize', e);
                });
            }
            if (g.top && p.allowTopResize)
            {
                g.topDropHandle = $("<div class='l-layout-drophandle-top'></div>");
                g.layout.append(g.topDropHandle);
                g.topDropHandle.show();
                g.topDropHandle.mousedown(function (e)
                {
                    g._start('topresize', e);
                });
            }
            if (g.bottom && p.allowBottomResize)
            {
                g.bottomDropHandle = $("<div class='l-layout-drophandle-bottom'></div>");
                g.layout.append(g.bottomDropHandle);
                g.bottomDropHandle.show();
                g.bottomDropHandle.mousedown(function (e)
                {
                    g._start('bottomresize', e);
                });
            }
            g.draggingxline = $("<div class='l-layout-dragging-xline'></div>");
            g.draggingyline = $("<div class='l-layout-dragging-yline'></div>");
            g.mask = $("<div class='l-dragging-mask'></div>");
            g.layout.append(g.draggingxline).append(g.draggingyline).append(g.mask);
        },
        _setDropHandlePosition: function ()
        {
            var g = this, p = this.options;
            if (g.leftDropHandle)
            {
                g.leftDropHandle.css({ left: g.left.width() + parseInt(g.left.css('left')), height: g.middleHeight, top: g.middleTop });
            }
            if (g.rightDropHandle)
            {
                g.rightDropHandle.css({ left: parseInt(g.right.css('left')) - p.space, height: g.middleHeight, top: g.middleTop });
            }
            if (g.topDropHandle)
            {
                g.topDropHandle.css({ top: g.top.height() + parseInt(g.top.css('top')), width: g.top.width() });
            }
            if (g.bottomDropHandle)
            {
                g.bottomDropHandle.css({ top: parseInt(g.bottom.css('top')) - p.space, width: g.bottom.width() });
            }
        },
        _onResize: function ()
        { 
            var g = this, p = this.options;
            var oldheight = g.layout.height();
            //set layout height 
            var h = 0;
            var windowHeight = $(window).height();
            var windowWidth = $(window).width();
            var parentHeight = null;
//            if (typeof (p.height) == "string" && p.height.indexOf('%') > 0)
//            {
//                var layoutparent = g.layout.parent();
//                if (p.inWindow || layoutparent[0].tagName.toLowerCase() == "body")
//                {
//                    parentHeight = windowHeight;
//                    parentHeight -= parseInt($('body').css('paddingTop'));
//                    parentHeight -= parseInt($('body').css('paddingBottom'));
//                }
//                else
//                {
//                    parentHeight = layoutparent.height();
//                }
//                h = parentHeight * parseFloat(p.height) * 0.01;
//                if (p.inWindow || layoutparent[0].tagName.toLowerCase() == "body")
//                {
//                    h -= (g.layout.offset().top - parseInt($('body').css('paddingTop')));
//                }
//            }
//            else
//            {
//                h = parseInt(p.height);
//            }
            var layoutparent = g.layout.parent();
            if(layoutparent[0].tagName.toLowerCase() != "body"){
            	//layoutparent.height(windowHeight-(p.outerMargin||0));
            	//layoutparent.width(windowWidth-(p.outerMargin||0));
            	layoutparent.height(windowHeight - (p.topOffset||0) -6);
            	layoutparent.width(windowWidth-8);
            }
            g.layout.height(layoutparent.height());
            g.layout.width(layoutparent.width());
            g.layoutHeight = g.layout.height();
            g.middleWidth = g.layout.width();
            g.middleHeight = g.layout.height();
            if (g.top)
            {
                g.middleHeight -= g.top.height();
                g.middleHeight -= parseInt(g.top.css('borderTopWidth'));
                g.middleHeight -= parseInt(g.top.css('borderBottomWidth'));
                g.middleHeight -= p.space;
            }
            if (g.bottom)
            {
                g.middleHeight -= g.bottom.height();
                g.middleHeight -= parseInt(g.bottom.css('borderTopWidth'));
                g.middleHeight -= parseInt(g.bottom.css('borderBottomWidth'));
                g.middleHeight -= p.space;
            }
            //specific
            g.middleHeight -= 2;

            if (g.hasBind('heightChanged') && g.layoutHeight != oldheight)
            {
                g.trigger('heightChanged', [{ layoutHeight: g.layoutHeight, diff: g.layoutHeight - oldheight, middleHeight: g.middleHeight}]);
            }

            if (g.center)
            {
                g.centerWidth = g.middleWidth;
                if (g.left)
                {
                    if (g.isLeftCollapse)
                    {
                        g.centerWidth -= g.leftCollapse.width();
                        g.centerWidth -= parseInt(g.leftCollapse.css('borderLeftWidth'));
                        g.centerWidth -= parseInt(g.leftCollapse.css('borderRightWidth'));
                        g.centerWidth -= parseInt(g.leftCollapse.css('left'));
                        g.centerWidth -= p.space;
                    }
                    else
                    {
                        g.centerWidth -= g.leftWidth;
                        g.centerWidth -= parseInt(g.left.css('borderLeftWidth'));
                        g.centerWidth -= parseInt(g.left.css('borderRightWidth'));
                        g.centerWidth -= parseInt(g.left.css('left'));
                        g.centerWidth -= p.space;
                    }
                }
                if(g.ctabs && g.ctabs.is(":visible"))
            	{
                	g.centerWidth -= g.ctabsWidth;
                    g.centerWidth -= parseInt(g.ctabs.css('borderLeftWidth'));
                    g.centerWidth -= parseInt(g.ctabs.css('borderRightWidth'));
                   // g.centerWidth -= parseInt(g.ctabs.css('left'));
                    g.centerWidth -= p.space;
            	}
                if (g.right && !g.righthided)
                {
                    if (g.isRightCollapse)
                    {
                        g.centerWidth -= g.rightCollapse.width();
                        g.centerWidth -= parseInt(g.rightCollapse.css('borderLeftWidth'));
                        g.centerWidth -= parseInt(g.rightCollapse.css('borderRightWidth'));
                        g.centerWidth -= parseInt(g.rightCollapse.css('right'));
                        g.centerWidth -= p.space;
                    }
                    else
                    {
                        g.centerWidth -= g.rightWidth;
                        g.centerWidth -= parseInt(g.right.css('borderLeftWidth'));
                        g.centerWidth -= parseInt(g.right.css('borderRightWidth'));
                        g.centerWidth -= p.space;
                    }
                }
                g.centerLeft = 0;
                if (g.left)
                {
                    if (g.isLeftCollapse)
                    {
                        g.centerLeft += g.leftCollapse.width();
                        g.centerLeft += parseInt(g.leftCollapse.css('borderLeftWidth'));
                        g.centerLeft += parseInt(g.leftCollapse.css('borderRightWidth'));
                        g.centerLeft += parseInt(g.leftCollapse.css('left'));
                        g.centerLeft += p.space;
                    }
                    else
                    {
                        g.centerLeft += g.left.width();
                        g.centerLeft += parseInt(g.left.css('borderLeftWidth'));
                        g.centerLeft += parseInt(g.left.css('borderRightWidth'));
                        g.centerLeft += p.space;
                    }
                }
                
                if(g.ctabs)
                {
                	g.ctabs.css({ left: g.centerLeft });
                    g.ctabs.height(g.middleHeight);
                    
                    if(g.ctabs.is(":visible"))
                    {
                    	g.centerLeft += g.ctabsWidth;
                    	g.centerLeft += parseInt(g.ctabs.css('borderLeftWidth'));
                        g.centerLeft += parseInt(g.ctabs.css('borderRightWidth'));
                        g.centerLeft += p.space;
                    }
                }
                
                g.center.css({ left: g.centerLeft });
                g.center.width(g.centerWidth);
                g.center.height(g.middleHeight);
                var contentHeight = g.middleHeight;
                if (g.center.header)
                {
                	contentHeight -= g.center.header.outerHeight();
                }
                g.center.content.height(contentHeight);
                if(g.ctabs){
                	 g.ctabs.content.height(contentHeight);
                }
                
                //表格高度
                if(g.center.tablegridout){
                	var h = contentHeight;
                	if(g.center.searchform)
                	{
                		var sform = $('.search:visible', g.center.maincontainer);
                		h -= sform.outerHeight();
                		h -= parseInt(sform.css('marginBottom'));
                	}
                	var heightCorrect = 18;//高度纠正，当出现横向滚动条时减去滚动条高度（约18px）
                	if(g.center.maincontainer && g.center.maincontainer.is(":visible"))
                	{
                		var w1 = g.center.content.width();
                        var w2 = g.center.maincontainer.width();
                        if(w1>=w2){//如果没有横向滚动条，高度不变
                        	heightCorrect = 0;
                        }
                    }
                	g.center.tablegridout.height(h-heightCorrect);
                }
                
            }
            if (g.left)
            {
                g.leftCollapse.height(g.middleHeight);
                g.left.height(g.middleHeight);
				var contentHeight = g.middleHeight;
                if (g.left.header)
                {
                	contentHeight -= g.left.header.outerHeight();
                }
				if (g.left.tabsbar && g.left.tabsbar.is(":visible"))
				{
					contentHeight -= g.left.tabsbar.outerHeight();
				}
				g.left.content.height(contentHeight);
				
				if(g.left.ZTree)
				{
					if(g.left.niceScrollObj){
						if(g.left.ZTree.outerHeight(true) > g.left.content.height()){
							g.left.niceScrollObj.onResize();
						}
					}else{
						g.left.ZTree.css("height", (g.left.content.innerHeight()-10)+"px");
					}
				}
				if(g.left.accordion)
				{
					g.left.accordion.setHeight();
				}
            }
            if (g.right)
            {
                g.rightCollapse.height(g.middleHeight);
                g.right.height(g.middleHeight);
				var contentHeight = g.middleHeight;
                if (g.right.header)
                {
                	contentHeight -= g.right.header.outerHeight();
                }
				g.right.content.height(contentHeight);
                //set left
                g.rightLeft = 0;

                if (g.left)
                {
                    if (g.isLeftCollapse)
                    {
                        g.rightLeft += g.leftCollapse.width();
                        g.rightLeft += parseInt(g.leftCollapse.css('borderLeftWidth'));
                        g.rightLeft += parseInt(g.leftCollapse.css('borderRightWidth'));
                        g.rightLeft += p.space;
                    }
                    else
                    {
                        g.rightLeft += g.left.width();
                        g.rightLeft += parseInt(g.left.css('borderLeftWidth'));
                        g.rightLeft += parseInt(g.left.css('borderRightWidth'));
                        g.rightLeft += parseInt(g.left.css('left'));
                        g.rightLeft += p.space;
                    }
                }
                if(g.ctabs && g.ctabs.is(":visible"))
                {
                	g.rightLeft += g.ctabsWidth;
                	g.rightLeft += parseInt(g.ctabs.css('borderLeftWidth'));
                    g.rightLeft += parseInt(g.ctabs.css('borderRightWidth'));
                    g.rightLeft += p.space;
                }
                if (g.center)
                {
                    g.rightLeft += g.center.width();
                    g.rightLeft += parseInt(g.center.css('borderLeftWidth'));
                    g.rightLeft += parseInt(g.center.css('borderRightWidth'));
                    g.rightLeft += p.space;
                }
                g.right.css({ left: g.rightLeft });
            }
            if (g.bottom)
            {
                g.bottomTop = g.layoutHeight - g.bottom.height() - 2;
                g.bottom.css({ top: g.bottomTop });
            }
            g._setDropHandlePosition();
			
			if (g.hasBind('sizeChanged'))
            {
                g.trigger('sizeChanged', [{
						layoutHeight: g.layoutHeight,
						heightDiff: (g.layoutHeight != oldheight)?(g.layoutHeight - oldheight):0,
						middleHeight: g.middleHeight,
						layoutWidth: g.layout.width(),
						topWidth: g.top?g.top.width():0,
						leftWidth: g.left?g.left.width():0,
						centerWidth: g.center?g.center.width():0,
						rightWidth: g.right?g.right.width():0,
						bottomWidth: g.bottom?g.bottom.width():0
					}]);
            }
        },
        _start: function (dragtype, e)
        {
            var g = this, p = this.options;
            g.dragtype = dragtype;
            if (dragtype == 'leftresize' || dragtype == 'rightresize')
            {
                g.xresize = { startX: e.pageX };
                g.draggingyline.css({ left: e.pageX - g.layout.offset().left, height: g.middleHeight, top: g.middleTop }).show();
                $('body').css('cursor', 'col-resize');
                g.mask.height(g.layout.height()).removeClass("l-layout-ymask").addClass("l-layout-xmask").show();
            }
            else if (dragtype == 'topresize' || dragtype == 'bottomresize')
            {
                g.yresize = { startY: e.pageY };
                g.draggingxline.css({ top: e.pageY - g.layout.offset().top, width: g.layout.width() }).show();
                $('body').css('cursor', 'row-resize');
                g.mask.height(g.layout.height()).removeClass("l-layout-xmask").addClass("l-layout-ymask").show();
            }
            else
            {
                return;
            }

            g.layout.lock.width(g.layout.width());
            g.layout.lock.height(g.layout.height());
            g.layout.lock.show();
            if ($.browser.msie || $.browser.safari)
            {
            	$('body').bind('selectstart.layout3drag', function () { return false; }); // 不能选择
            }
            $(document).bind('mouseup.layout3drag', function ()
            {
                g._stop.apply(g, arguments);
            });
            $(document).bind('mousemove.layout3drag', function ()
            {
                g._drag.apply(g, arguments);
            });
        },
        _drag: function (e)
        {
            var g = this, p = this.options;
            if (g.xresize)
            {
                g.xresize.diff = e.pageX - g.xresize.startX;
                g.draggingyline.css({ left: e.pageX - g.layout.offset().left });
                $('body').css('cursor', 'col-resize');
            }
            else if (g.yresize)
            {
                g.yresize.diff = e.pageY - g.yresize.startY;
                g.draggingxline.css({ top: e.pageY - g.layout.offset().top });
                $('body').css('cursor', 'row-resize');
            }
        },
        _stop: function (e)
        {
            var g = this, p = this.options;
            var diff;
            if (g.xresize && g.xresize.diff != undefined)
            {
                diff = g.xresize.diff;
                if (g.dragtype == 'leftresize')
                {
                    if (p.minLeftWidth)
                    {
                        if (g.leftWidth + g.xresize.diff < p.minLeftWidth)return;
                    }
                    g.leftWidth += g.xresize.diff;
                    g.left.width(g.leftWidth);
                    if (g.center)
                    {
                        g.center.width(g.center.width() - g.xresize.diff).css({ left: parseInt(g.center.css('left')) + g.xresize.diff });
                    }
                    else if (g.right)
                    {
                        g.right.width(g.left.width() - g.xresize.diff).css({ left: parseInt(g.right.css('left')) + g.xresize.diff });
                    }
                }
                else if (g.dragtype == 'rightresize')
                {
                    if (p.minRightWidth)
                    {
                        if (g.rightWidth - g.xresize.diff < p.minRightWidth)return;
                    }
                    g.rightWidth -= g.xresize.diff;
                    g.right.width(g.rightWidth).css({ left: parseInt(g.right.css('left')) + g.xresize.diff });
                    if (g.center)
                    {
                        g.center.width(g.center.width() + g.xresize.diff);
                    }
                    else if (g.left)
                    {
                        g.left.width(g.left.width() + g.xresize.diff);
                    }
                }
            }
            else if (g.yresize && g.yresize.diff != undefined)
            {
                diff = g.yresize.diff;
                if (g.dragtype == 'topresize')
                {
                    g.top.height(g.top.height() + g.yresize.diff);
                    g.middleTop += g.yresize.diff;
                    g.middleHeight -= g.yresize.diff;
                    if (g.left)
                    {
                        g.left.css({ top: g.middleTop }).height(g.middleHeight);
                        g.leftCollapse.css({ top: g.middleTop }).height(g.middleHeight);
                    }
                    if (g.center)
                    {
                    	g.center.css({ top: g.middleTop }).height(g.middleHeight);
                    }
                    if (g.right)
                    {
                        g.right.css({ top: g.middleTop }).height(g.middleHeight);
                        g.rightCollapse.css({ top: g.middleTop }).height(g.middleHeight);
                    }
                }
                else if (g.dragtype == 'bottomresize')
                {
                    g.bottom.height(g.bottom.height() - g.yresize.diff);
                    g.middleHeight += g.yresize.diff;
                    g.bottomTop += g.yresize.diff;
                    g.bottom.css({ top: g.bottomTop });
                    if (g.left)
                    {
                        g.left.height(g.middleHeight);
                        g.leftCollapse.height(g.middleHeight);
                    }
                    if (g.center)
                    {
                    	g.center.height(g.middleHeight);
                    }
                    if (g.right)
                    {
                        g.right.height(g.middleHeight);
                        g.rightCollapse.height(g.middleHeight);
                    }
                }
            }
            g.trigger('endResize', [{
                direction: g.dragtype ? g.dragtype.replace(/resize/, '') : '',
                diff: diff
            }, e]);
            g._setDropHandlePosition();
            g.draggingxline.hide();
            g.draggingyline.hide();
            g.mask.hide();
            g.xresize = g.yresize = g.dragtype = false;
            g.layout.lock.hide();
            if ($.browser.msie || $.browser.safari)
            {
                $('body').unbind('selectstart.layout3drag');
            }
            $(document).unbind('mousemove.layout3drag', g._drag);
            $(document).unbind('mouseup.layout3drag', g._stop);
            $('body').css('cursor', '');

        },
        getAjaxData: function(url, param, callback, returndata)
        {
        	var g = this;
        	$.ajax({
        		type: (param.type||'get'),
        		url: url,
        		data: (param.data||''),
        		async: param.async==null?true:param.async,
        		dataType: (param.dataType||'json'),
        		cache: false,
        		beforeSend: function ()
        		{
	        		if(param.loading && g.center.loading)
	        		{
	        			g.center.loading.show();
	        		}
	        	},
        		success: function(data){
        			if(data && this.dataType=='json' && typeof(data)=='string')
        			{
        				data = $.trim(data);
        				data = $.parseJSON(data);
        			}
        			callback.call(g, data, returndata);
        		},
        		complete: function ()
        		{
        			if(g.center.loading)
        			{
        				g.center.loading.hide();
        			}
        		},
				error: function (XMLHttpRequest, textStatus, errorThrown)
				{
					g.trigger('error', [XMLHttpRequest, textStatus, errorThrown, url]);
				}
        	});
        },
        _getUrl: function(url)
        {
        	var g = this, p = this.options;
        	
        	var _url = url.replace(/\$\{(.+?)}/g, function(word, key){
				switch(key){
				case 'path': return p.basepath;
				case 'basepath': return p.basepath;
				case 'filepath': return p.filepath;
				case 'respath': return p.respath;
				case 'iconpath': return p.iconpath;
				default:
					if(g._sysParams){
						if(key.indexOf('.') == -1){
							return g._sysParams[key];
						}else{
							try{
								return new Function("data", "return data."+key+";")(g._sysParams);
							}catch(e){
								return word;
							}
						}
					}else{
						return word;
					}
				}
			});
        	url = _url;
        	var rs = /^(\w+):\/\/(.+)$/g.exec(url);
        	if(rs!=null){
        		url = rs[1] + '://' + rs[2].replace(/[\\\/]+/gi, '/');
        	}else{
        		url = url.replace(/[\\\/]+/gi, '/');
        	}
        	return url;
        },
        _parseFields: function(record, _temp)
        {
        	var _text = _temp.replace(/#\{(.+?)}/g, function(word, key){
        		if(key.indexOf('.') == -1){
        			if(record[key]===0 || record[key]===false || record[key]===''){
        				return record[key];
        			}
        			return !!record[key] ? record[key] : word;
				}else{
					try{
						var txt = new Function("record", "return record."+key+";")(record);
						if(txt===0 || txt===false || txt===''){
	        				return txt;
	        			}
						return txt || word;
					}catch(e){
						return word;
					}
				}
			});
        	return _text;
        },
        _parseSysParam: function(_temp){
        	var _text = _temp.replace(/#\{(.+?)}/g, function(word, key){
        		try{
        			return new Function("obj", "return obj."+key+";")(g.globalObj) || word;
        		}catch(e){
        			return word;
        		}
        	});
        	return _text;
        },
        _isLocalUrl: function(url)
        {
        	url = url.toLowerCase();
        	if(!(/^(\w+):\/\/.+$/.test(url))){
        		return true;
        	}
        	var local = location.protocol+'//'+location.host;
        	if(url.indexOf(local)==0)
        	{
        		return true;
        	}
        	return false;
        },
        _notEmpty: function(str)//判断字符串是否非空
        {
        	return (str && $.trim(str).length>0);
        },
        _isEmpty: function(str)//判断字符串是否空
        {
        	return (!str || $.trim(str).length==0);
        },
        _getIconPath: function(iconPath)
        {
        	var g = this, p = this.options;
        	iconPath = g._getUrl(iconPath);
        	if(/^(\w+):\/\/.+$/.test(iconPath)){
        		return iconPath;
        	}
        	if(iconPath.charAt(0)=='/'){
        		return iconPath;
        	}
        	return p.iconpath + '/' + iconPath;
        },
        _mergeUrlParam: function(url, ignoreGlobalParam, useCenterData, paramList)
        {
        	var g = this, p = this.options;
        	if(!ignoreGlobalParam){
				//全局参数
				if(url.indexOf('?')==-1){
					url += '?';
				}else{
					url += '&';
				}
				url += $.param(g._getGlobalParam());
				url += '&r='+Math.random();
			}
			if(!!useCenterData && g._notEmpty(g.globalParam.centerdata)){
				if(url.indexOf('?')==-1){
					url += '?';
				}else{
					url += '&';
				}
				var ids = g.globalParam.centerdata.split(';');
				for(var ii=0; ii<ids.length; ii++){
					if(ii>0){
						url += '&';
					}
					url += g.globalObj.centerConf.idfield+'='+ids[ii];
				}
			}
			if(paramList){
				if(url.indexOf('?')==-1){
					url += '?';
				}else{
					url += '&';
				}
				for(var ii=0; ii<paramList.length; ii++){
					if(ii>0){
						url += '&';
					}
					url += paramList[ii].name+'='+paramList[ii].value;
				}
			}
        	return url;
        },
        _callInit: function(iwin, funcName, params)
        {
        	var result = false;
        	try{
        		if(typeof(iwin[funcName])=='function')
    			{
        			iwin[funcName].call(this, this, params);
        			result = true;
    				if(!(delete iwin[funcName]))
    				{
    					iwin[funcName] = null;
    				}
    			}
        	}catch(err){
        	}
        	return result;
        },
        _deleteFunc: function(iwin, funcName){
        	try{
        		if(typeof(iwin[funcName])=='function')
    			{
    				if(!(delete iwin[funcName]))
    				{
    					iwin[funcName] = null;
    				}
    			}
        	}catch(err){
        	}
        },
        //将一个以管道符[|]分割的字符串转为Map
        _pipeStrToMap: function(pipeStr){
        	var map = {};
        	if(pipeStr==null || pipeStr==''){
        		return map;
        	}
        	var arr = pipeStr.split('|');
        	for(var i=0; i<arr.length; i++){
        		map[arr[i]] = true;
        	}
        	return map;
        },
        _filterHidein: function(arr){
        	var g = this, p = this.options;
        	if(!arr)return;
        	for(var i=arr.length-1; i>=0; i--){
				var itm = arr[i];
				if(!itm.hidein)continue;
				if(g._pipeStrToMap(itm.hidein)[g.globalParam.datatype]){
					arr.splice(i, 1);
				}
			}
        }
        
    });

})(jQuery);